Title: imaplib documentation claims that commands return a string, but they return bytes
Type: behavior Stage: resolved
Components: email Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: andrei.avk, barry, dkg, kj, r.david.murray
Priority: normal Keywords:

Created on 2020-01-24 20:24 by dkg, last changed 2021-09-09 21:29 by andrei.avk. This issue is now closed.

Messages (3)
msg360652 - (view) Author: Daniel Kahn Gillmor (dkg) * Date: 2020-01-24 20:24
The imaplib documentation says:

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

However, "Each data is either a string, or a tuple" does not appear to be correct.   If the element of data is not a tuple, it appears to be a bytes object, not a string (because it is dealing with network streams of bytes internally)

This is probably old documentation left over from python 2, when strings and bytes were the same.
msg360658 - (view) Author: Daniel Kahn Gillmor (dkg) * Date: 2020-01-24 21:38
I should note that the "header of the response" appears to also be a bytes object, not a string object.
msg401522 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-09-09 21:29
This issue was fixed in -- closing.
Date User Action Args
2021-09-09 21:29:07andrei.avksetstatus: open -> closed

versions: + Python 3.9, - Python 3.7, Python 3.8
nosy: + kj, andrei.avk

messages: + msg401522
resolution: fixed
stage: resolved
2020-01-24 21:38:50dkgsetmessages: + msg360658
2020-01-24 20:24:36dkgcreate