-
-
Notifications
You must be signed in to change notification settings - Fork 32k
logging.handlers.SMTPHandler: secure argument is broken in Python 3.12+ #127712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
vsajip
pushed a commit
that referenced
this issue
Feb 10, 2025
…H-127726) GH-127712: Fix `secure` argument of `logging.handlers.SMTPHandler` Python 3.12 removed support for the `keyfile` and `certfile` parameters in `smtplib.SMTP.starttls()`, requiring a `ssl.SSLContext` instead. `SMTPHandler` now creates a context from the `secure` tuple and passes that to `starttls`.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Feb 10, 2025
…er` (pythonGH-127726) pythonGH-127712: Fix `secure` argument of `logging.handlers.SMTPHandler` Python 3.12 removed support for the `keyfile` and `certfile` parameters in `smtplib.SMTP.starttls()`, requiring a `ssl.SSLContext` instead. `SMTPHandler` now creates a context from the `secure` tuple and passes that to `starttls`. (cherry picked from commit d7672e5) Co-authored-by: s-hamann <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Feb 10, 2025
…er` (pythonGH-127726) pythonGH-127712: Fix `secure` argument of `logging.handlers.SMTPHandler` Python 3.12 removed support for the `keyfile` and `certfile` parameters in `smtplib.SMTP.starttls()`, requiring a `ssl.SSLContext` instead. `SMTPHandler` now creates a context from the `secure` tuple and passes that to `starttls`. (cherry picked from commit d7672e5) Co-authored-by: s-hamann <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Bug description:
The documentation for
logging.handlers.SMTPHandler
describes thesecure
argument as follows:However, from Python 3.12 on, only the empty tuple actually works.
With a single-value-tuple or a two-value-tuple,
smtplib.SMTP.starttls()
throws an exception like this:The reason seems immediately obvious from the last sentence in the description of the
secure
argument: The tuple is passed tosmtplib.SMTP.starttls()
.The documentation for this method states:
SMTPHandler
still relies on the these parameters.Here's a minimal script to reproduce the error (requires a mocked SMTP server on port 1025):
Note that Python 3.11 is not affected and the above code successfully attempts to issue a STARTTLS command.
CPython versions tested on:
3.11, 3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
secure
argument oflogging.handlers.SMTPHandler
#127726secure
argument oflogging.handlers.SMTPHandler
(GH-127726) #129955secure
argument oflogging.handlers.SMTPHandler
(GH-127726) #129956The text was updated successfully, but these errors were encountered: