Author norbertcyran
Recipients docs@python, norbertcyran
Date 2020-08-31.09:41:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Documentation on IMAP4 class specifies wrong return type of its commands:

    Each command returns a tuple: (type, [data, ...]) where type is 
    usually 'OK' or 'NO', and data is either the text from the command 
    response, or mandated results from the command. Each data is either a 
    string, or a tuple. If a tuple, then the first part is the header of 
    the response, and the second part contains the data (ie: ‘literal’ 

That's not valid for Python 3, as IMAP4 commands return bytes-like objects in data, what's shown in the example before::
  >>> from imaplib import IMAP4
  >>> with IMAP4("") as M:
  ...     M.noop()
  ('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])

That of course can cause a lot of trouble due to incompatibility of strings and bytes. Suggested change is to replace string occurences to bytes-like object. I don't know what types are returned in case when tuple is returned though.
Date User Action Args
2020-08-31 09:41:11norbertcyransetrecipients: + norbertcyran, docs@python
2020-08-31 09:41:11norbertcyransetmessageid: <>
2020-08-31 09:41:11norbertcyranlinkissue41672 messages
2020-08-31 09:41:10norbertcyrancreate