Skip to content

Simplify IMAP4_TLS class and fix Python 3.14+ compatibility#629

Merged
mjs merged 4 commits into
mjs:masterfrom
seanthegeek:master
Jan 2, 2026
Merged

Simplify IMAP4_TLS class and fix Python 3.14+ compatibility#629
mjs merged 4 commits into
mjs:masterfrom
seanthegeek:master

Conversation

@seanthegeek

@seanthegeek seanthegeek commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Fix #618 without needing to access undocumented Python imaplib attributes that should not be modified, such as file. Tested against Gmail IMAP TLS on Python 3.8, 3.13, and 3.14 using this test script

import ssl
from imapclient import IMAPClient


HOST = "imap.gmail.com"
PORT = 993


def main() -> None:
    ctx = ssl.create_default_context()
    with IMAPClient(
        HOST,
        port=PORT,
        ssl=True,
        ssl_context=ctx,
        timeout=30,
    ) as client:
        print("Connected to:", HOST, PORT)
        print("welcome:", client.welcome)

        caps = client.capabilities()
        print("capabilities:", caps)
        print("Successfully connected and ran CAPABILITY without auth.")


if __name__ == "__main__":
    main()

See also

python/cpython#142307
seanthegeek/mailsuite#15
domainaware/parsedmarc#636

@JohnVillalovos

Copy link
Copy Markdown
Contributor

Would it also make sense to update .github/workflows/main.yml to use Python 3.14?

@seanthegeek

seanthegeek commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

Would it also make sense to update .github/workflows/main.yml to use Python 3.14?

Good point. Added to workflow and updated docs.

@mjs

mjs commented Dec 30, 2025

Copy link
Copy Markdown
Owner

Thank you very much for this - an excellent change. Would you be able to address the black formatting issue? I'll then get this merged.

@seanthegeek

Copy link
Copy Markdown
Contributor Author

Done

@mjs mjs merged commit 73b2cea into mjs:master Jan 2, 2026
8 of 9 checks passed
@mjs

mjs commented Jan 2, 2026

Copy link
Copy Markdown
Owner

Thanks! There's still a flake8 issue (unused import) but I'll merge and fix this myself.

@jmartens

jmartens commented Jan 5, 2026

Copy link
Copy Markdown

Any changes a release is made with this fix included?

@mjs

mjs commented Jan 17, 2026

Copy link
Copy Markdown
Owner

Release 3.1.0 has just been done and includes this fix. Thanks!

gauravjuvekar added a commit to gauravjuvekar/remote-email-filtering that referenced this pull request May 18, 2026
AndrewKvalheim added a commit to AndrewKvalheim/dmarc-report-notifier that referenced this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: property 'file' of 'IMAP4_TLS' object has no setter on Python 3.14

4 participants