New submission from Norbert Cyran <cyran.norber...@gmail.com>:

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’ 
    value).

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("domain.org") 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.

----------
assignee: docs@python
components: Documentation
messages: 376143
nosy: docs@python, norbertcyran
priority: normal
severity: normal
status: open
title: imaplib: wrong return type documented
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41672>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to