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

incorrect example of fetching messages in imaplib documentation #79964

Open
mvarnar mannequin opened this issue Jan 19, 2019 · 1 comment
Open

incorrect example of fetching messages in imaplib documentation #79964

mvarnar mannequin opened this issue Jan 19, 2019 · 1 comment
Labels
3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir topic-email type-feature A feature request or enhancement

Comments

@mvarnar
Copy link
Mannequin

mvarnar mannequin commented Jan 19, 2019

BPO 35783
Nosy @warsaw, @bitdancer, @mvarnar, @rahul-kumi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-01-19.08:40:17.372>
labels = ['3.8', 'type-feature', '3.7', 'expert-email', 'docs']
title = 'incorrect example of fetching messages in imaplib documentation'
updated_at = <Date 2020-12-22.16:16:47.334>
user = 'https://github.com/mvarnar'

bugs.python.org fields:

activity = <Date 2020-12-22.16:16:47.334>
actor = 'rahul-kumi'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'email']
creation = <Date 2019-01-19.08:40:17.372>
creator = 'Max Varnar'
dependencies = []
files = []
hgrepos = []
issue_num = 35783
keywords = []
message_count = 1.0
messages = ['334048']
nosy_count = 5.0
nosy_names = ['barry', 'r.david.murray', 'docs@python', 'Max Varnar', 'rahul-kumi']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue35783'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8']

@mvarnar
Copy link
Mannequin Author

mvarnar mannequin commented Jan 19, 2019

An example of fetching messages from the mailbox given in "IMAP4 Example" section is incorrect:

typ, data = M.fetch(num, '(RFC822)')
print('Message %s\n%s\n' % (num, data[0][1]))

"fetch" may return server data that was not requested (see "7.4.2. FETCH Response" section of RFC 3501). In that case "data[0][1]" won't return what user expects.
This is a bad example, that many people repeat and advise to other developers:
https://stackoverflow.com/questions/13210737/get-only-new-emails-imaplib-and-python
https://gist.github.com/robulouski/7441883
https://stackoverflow.com/questions/51098962/check-if-email-inbox-is-empty-imaplib-python3
https://stackoverflow.com/questions/21116498/imaplib-not-getting-all-emails-in-folder
https://stackoverflow.com/questions/2230037/how-to-fetch-an-email-body-using-imaplib-in-python

I guess, this peculiarity should be clarified in the documentation. I offer to mark this fetching method is not safe and requests careful fetch result parsing.

@mvarnar mvarnar mannequin added 3.7 (EOL) end of life 3.8 only security fixes labels Jan 19, 2019
@mvarnar mvarnar mannequin assigned docspython Jan 19, 2019
@mvarnar mvarnar mannequin added docs Documentation in the Doc dir topic-email type-feature A feature request or enhancement labels Jan 19, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir topic-email type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants