-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-137339: Clarify host and port parameter behavior in smtplib.SMTP_SSL initialization #137340
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this requires a change as we already mention what happens when the optional parameters are given. If you want to rephrase it, you should remove the "if the optional parameters are given then [...¨]" as it makes the paragraph more confusing IMO.
Doc/library/smtplib.rst
Outdated
called with those parameters during initialization.If *host* is omitted or | ||
an empty string, no connection is made during initialization; you must | ||
call :meth:`connect` manually before using the instance. | ||
If *port* is zero, the default SMTP port (25) is used. If specified, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not always the case that the default SMTP port is 25. It depends on the default_port
attribute. Also, this now contradicts the last sentence:
If omitted (or if host or port are
''
and/or0
respectively) the OS default behavior will be used.
We should also make more paragraphs. This description is too compact for the reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If port is zero, the value of the instance's default_port attribute will be used.
I'd appreciate any insights or suggestions to expand our descriptions so that its not too compact for reader
Doc/library/smtplib.rst
Outdated
@@ -26,7 +26,10 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions). | |||
An :class:`SMTP` instance encapsulates an SMTP connection. It has methods | |||
that support a full repertoire of SMTP and ESMTP operations. If the optional | |||
*host* and *port* parameters are given, the SMTP :meth:`connect` method is | |||
called with those parameters during initialization. If specified, | |||
called with those parameters during initialization.If *host* is omitted or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already hinted in the previous sentence and this would somehow conflict with the last sentence IMO.
If the optional host and port parameters are given, the SMTP :meth:
connect
method is called with those parameters during initialization
Thankyou for the feedback ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment from the issue:
As for this one,
If the optional host and port parameters are given, connect() is called with those parameters during initialization. If host is omitted or empty, no connection is made; connect() must be called manually. If port is zero, the default SMTP port (25) is used.
I think we can simplify by stating that host is not optional. connect
is linked and there you can find further details on behaviour, duplicate docs will simply create problems down the line.
The host and optional port arguments are passed to
connect
during initialization.
It is optional though?
This is incorrect. connect() is only called in |
@picnixz |
(GH #137339)
This PR updates the documentation for the smtplib.SMTP_SSL class to explicitly clarify the behavior of the host and port parameters during initialization.
Specifically, it now states that if host is omitted or an empty string, no connection is made during initialization and connect() must be called manually. It also clarifies that if port is zero,
Please let me know if this fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thankyou!
📚 Documentation preview 📚: https://cpython-previews--137340.org.readthedocs.build/