[issue35783] incorrect example of fetching messages in imaplib documentation

New submission from Макс Вернер <mvarnar@gmail.com>: 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... https://gist.github.com/robulouski/7441883 https://stackoverflow.com/questions/51098962/check-if-email-inbox-is-empty-i... https://stackoverflow.com/questions/21116498/imaplib-not-getting-all-emails-... https://stackoverflow.com/questions/2230037/how-to-fetch-an-email-body-using... 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. ---------- assignee: docs@python components: Documentation, email messages: 334048 nosy: barry, docs@python, r.david.murray, Макс Вернер priority: normal severity: normal status: open title: incorrect example of fetching messages in imaplib documentation type: enhancement versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35783> _______________________________________

Change by Rahul Kumaresan <kayrahul@gmail.com>: ---------- nosy: +rahul-kumi _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35783> _______________________________________
participants (2)
-
Rahul Kumaresan
-
Макс Вернер