Title: incorrect example of fetching messages in imaplib documentation
Type: enhancement Stage:
Components: Documentation, email Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Max Varnar, barry, docs@python, r.david.murray, rahul-kumi
Priority: normal Keywords:

Created on 2019-01-19 08:40 by Max Varnar, last changed 2020-12-22 16:16 by rahul-kumi.

Messages (1)
msg334048 - (view) Author: Max Varnar (Max Varnar) Date: 2019-01-19 08:40
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:

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.
Date User Action Args
2020-12-22 16:16:47rahul-kumisetnosy: + rahul-kumi
2019-01-19 08:40:17Max Varnarcreate