classification
Title: In imaplib, cached capabilities may be out of date after login
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mcepl, r.david.murray, sjmurdoch, vstinner
Priority: normal Keywords:

Created on 2013-09-04 14:27 by sjmurdoch, last changed 2018-07-19 11:59 by vstinner.

Messages (4)
msg196920 - (view) Author: Steven Murdoch (sjmurdoch) Date: 2013-09-04 14:27
When an IMAP server is behind a proxy, the proxy's capabilities may differ from that of the actual IMAP server. However, in Python imaplib, the client will ignore any updates to available capabilities in the response to the LOGIN command (see rfc3501, section 6.2.3). As a result, imaplib will incorrectly assume that certain features are not available (including the IDLE patch in issue 11245, and as implemented in getmail 4.43.0). imaplib should refresh its capability list either based on the result of the login command or by explicitly sending a CAPABILITY command following login.
msg196925 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-09-04 15:17
I agree that this would be a good idea, but it is not a bug in the current implementation.  The only place imaplib itself uses the cached capabilities is *before* login, in the starttls method, and there it refreshes it after starttls succeeds.

Although it isn't documented any more than the 'capabilities' attribute is (and therefor neither are part of the public API currently), you can call the capability command yourself if you need the refreshed capabilities in your own code.

Good catch on the bug in the IDLE patch, though.
msg315573 - (view) Author: Matej Cepl (mcepl) * Date: 2018-04-21 18:23
Well, and would it be too much to refresh capabilities attribute in the end of login method?
msg321954 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-19 11:59
See also bpo-33327: Add a method to move messages to IMAPlib.
History
Date User Action Args
2018-07-19 11:59:03vstinnersetnosy: + vstinner
messages: + msg321954
2018-04-21 18:23:55mceplsetnosy: + mcepl
messages: + msg315573
2014-12-30 09:52:03pitrousetversions: + Python 3.5, - Python 3.4
2013-09-04 15:18:59r.david.murraylinkissue11245 dependencies
2013-09-04 15:17:11r.david.murraysetversions: - Python 2.6, Python 3.1, Python 2.7, Python 3.2, Python 3.3, Python 3.5
nosy: + r.david.murray

messages: + msg196925

type: behavior -> enhancement
stage: needs patch
2013-09-04 14:27:30sjmurdochcreate