Skip to content

gh-63121: Refresh imaplib capabilities on state changes#152752

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-refresh-capabilities
Open

gh-63121: Refresh imaplib capabilities on state changes#152752
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-refresh-capabilities

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 1, 2026

Copy link
Copy Markdown
Member

imaplib fetched the server capabilities only once, at connection time,
and never updated them. But a server may advertise different
capabilities after authentication (:rfc:3501), so methods relying on
the cached list, such as enable(), wrongly reported that the server
did not support a capability it had advertised after login -- for
example ENABLE on Gmail (#103451).

Capabilities are now refreshed after a successful LOGIN or
AUTHENTICATE, from the CAPABILITY response the server sent or, if it
sent none, by querying it (as is already done after STARTTLS). As a
side benefit, capabilities advertised in the server greeting are now
used too, saving a redundant CAPABILITY command.

Fixes #103451.

imaplib fetched the server capabilities only once, at connection time.
They are now also refreshed after a successful LOGIN or AUTHENTICATE,
from the CAPABILITY response the server sent or, if it sent none, by
querying it.  This lets methods such as enable() see capabilities added
after login, for example ENABLE on Gmail (pythongh-103451).

Capabilities advertised in the server greeting are now used too, saving
a redundant CAPABILITY command.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka requested a review from a team as a code owner July 1, 2026 08:18
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

imaplib problem with the "Enable" capability

1 participant