Skip to content

Doc: Clarify smtplib server reply bytes - #149970

Open
savagemechanic wants to merge 1 commit into
python:mainfrom
savagemechanic:docs-smtplib-reply-bytes
Open

savagemechanic wants to merge 1 commit into
python:mainfrom
savagemechanic:docs-smtplib-reply-bytes

Conversation

@savagemechanic

@savagemechanic savagemechanic commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Docs-only change.

Clarifies that SMTP server reply messages returned by smtplib APIs are bytes, including SMTP.verify() responses and refused-recipient entries from SMTP.sendmail().

Local check:

make -C Doc check SPHINXOPTS='-W --keep-going'

@savagemechanic
savagemechanic requested a review from a team as a code owner May 18, 2026 01:17
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels May 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs May 18, 2026
@read-the-docs-community

read-the-docs-community Bot commented May 18, 2026 •

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 19, 2026

@bitdancer bitdancer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggesting this.

What about docmd, connect, and sendmail?

Comment thread Doc/library/smtplib.rst Outdated
:class:`bytes` object. If the user address is valid, *code* is 250 and
*message* contains a full :rfc:`822` address (including human name).
Otherwise *code* is an SMTP error code of 400 or greater and *message*
contains the error response.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good rewrite, but I think it would read better if we said "code is the response code from the server as an integer and message is..."

Comment thread Doc/library/smtplib.rst Outdated
and the accompanying error message sent by the server.
recipient that was refused. Each entry contains a ``(code, response)`` tuple,
where *code* is the SMTP error code and *response* is the accompanying server
error response as a :class:`bytes` object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here, "as an integer".

@bedevere-app

bedevere-app Bot commented Aug 22, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 25, 2026
@savagemechanic
savagemechanic force-pushed the docs-smtplib-reply-bytes branch from c740c99 to 8e57968 Compare October 1, 2026 15:00

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I rebased the change onto current main and addressed the requested areas.

docmd() and connect() now document the returned (code, message) tuple explicitly: the response code is an integer and the server response is bytes. I also made the code type explicit in verify() and sendmail(), aligned the corresponding source docstrings, and corrected the stale sendmail() bytes example.

While checking the same response contract, I found two directly related stale docstrings and corrected them as well: getreply() described the response message as a string, and data() described an integer-only return even though it returns (code, message). I also aligned the SMTPResponseException code/error attribute wording.

I inspected the other reply-returning paths but left them unchanged where they do not make a conflicting type or return-shape claim; expanding those would be a broader consistency rewrite rather than part of this focused correction.

I have made the requested changes; please review again.

@bedevere-app

bedevere-app Bot commented Oct 1, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@bitdancer: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from bitdancer October 1, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants