This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: imaplib Imap.select() uses comparison to 'None' for boolean
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: pierslauder Nosy List: jerub, pierslauder
Priority: normal Keywords:

Created on 2005-08-31 05:52 by jerub, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg26160 - (view) Author: Stephen Thorne (jerub) * Date: 2005-08-31 05:52
The imap class's method for selecting a mailbox in read
only mode is subtly broken. Calling i.select('INBOX',
readonly=0) will cause the imap library to open the
mailbox in EXAMINE mode, not SELECT.

     def select(self, mailbox='INBOX', readonly=None):
         if readonly is not None:
             name = 'EXAMINE'
         else:
             name = 'SELECT'

So passing what seems to be a boolean option into the
function causes unexpected circumstances in client code.

Recommend that the comparison be changed to 'if readonly:'.

I have verified this code exists in python2.3 and in
python cvs head.
msg26161 - (view) Author: Stephen Thorne (jerub) * Date: 2005-08-31 05:54
Logged In: YES 
user_id=100823

assigned to pierslauder as per abaxter's request.
msg26162 - (view) Author: Piers Lauder (pierslauder) * (Python triager) Date: 2005-08-31 10:32
Logged In: YES 
user_id=196212

The manual suggests that "set"ing the 'readonly' flag will
disable modifications, and I agree the suggested change
would produce the expected behaviour - will check in a fix...
msg26163 - (view) Author: Piers Lauder (pierslauder) * (Python triager) Date: 2005-08-31 10:48
Logged In: YES 
user_id=196212

Suggested change checked in.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42326
2005-08-31 05:52:53jerubcreate