Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Command class __repr__ method more robust #99

Merged

Conversation

BrentWilkins
Copy link
Contributor

I started some work based on one of imaplib's examples.

IMAP4 Example

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')  # ← This is more supported now
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()

I noticed that passing None as the first parameter got me an exception. To improve the robustness of the code, I added a generator expression that converts any NoneTypes to empty strings.

@bamthomas bamthomas merged commit 692b1e2 into bamthomas:master Dec 13, 2023
3 of 4 checks passed
@bamthomas
Copy link
Owner

thank you @BrentWilkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants