Repository navigation
In imaplib, cached capabilities may be out of date after login #63121
Description
Activity
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 bpo-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.
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Sep 4, 2013 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.
- addedtype-featureA feature request or enhancementA feature request or enhancementand removedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Sep 4, 2013 Well, and would it be too much to refresh capabilities attribute in the end of login method?
See also bpo-33327: Add a method to move messages to IMAPlib.
The inconsistency is a problem for the ENABLE capability support that was added in #65999; see #103451.
The capabilities attribute was already mentioned in the authenticate documentation as a collection (https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4.authenticate):
mechanism . . . should appear in the instance variable capabilities
- added 3 commits that reference this issue
on Jul 2, 2026 Fixed in #152752: imaplib now refreshes the cached capabilities after login and other state changes.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs