Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The docs for email.mime types incorrectly identify bytes as strings #101021

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

Closed
bkline opened this issue Jan 13, 2023 · 1 comment · Fixed by #101024
Closed

The docs for email.mime types incorrectly identify bytes as strings #101021

bkline opened this issue Jan 13, 2023 · 1 comment · Fixed by #101024
Assignees
Labels
docs Documentation in the Doc dir topic-email

Comments

@bkline
Copy link
Contributor

bkline commented Jan 13, 2023

Documentation

For example:

_imagedata is a string containing the raw image data. (image.py)

or

_audiodata is a string containing the raw audio data. (audio.py)

So the programmer thinks, "how can it be a 'string' and 'raw' at the same time?" Then the programmer notices the parameter for encoding and the language saying "the default encoding is Base64" and thinks, "ah, ok, that's how it could be a string!" (though it's still a little bit squirrelly to use the word "raw" to describe encoded data).

But then the reader sees the future tense in "... which will perform the actual encoding..." and thinks, "no, the argument must really be for binary data."

And then the programmer notices the parallel language in text.py:

_text is the string for this message object.

and starts to wonder: "huh, maybe all of these are expecting bytes." But then the programmer's code blows up when it tries to go with that theory (still no help from the documentation).

So in desperation, the programmer starts to dig into the actual code to find out what's done for each of these subclasses. And that journey leads to the conclusion that "string" in this package means one thing for some of the classes and something different for others.

Can't we just say "bytes" when we mean bytes, and reserve the use of the word "string" to mean what it's supposed to mean in the only versions of Python which are actually officially supported? 😆

Linked PRs

@bkline bkline added the docs Documentation in the Doc dir label Jan 13, 2023
bkline added a commit to bkline/cpython that referenced this issue Jan 13, 2023
The existing documentation refers to binary parameters as "strings" when
they are actually bytes.

Fixes python#101021
@warsaw
Copy link
Member

warsaw commented Jan 14, 2023

My guess is that all of this language is holdovers from the Python 2 days, so it's worth cleaning up.

bkline added a commit to bkline/cpython that referenced this issue Jan 14, 2023
The existing documentation refers to binary parameters as "strings" when
they are actually bytes.

Fixes python#101021
bkline added a commit to bkline/cpython that referenced this issue Jan 14, 2023
The existing documentation refers to binary parameters as "strings" when
they are actually bytes.

Fixes python#101021
bkline added a commit to bkline/cpython that referenced this issue Jan 14, 2023
The existing documentation refers to binary parameters as "strings" when
they are actually bytes.

Fixes python#101021
bkline added a commit to bkline/cpython that referenced this issue Jan 14, 2023
The existing documentation refers to binary parameters as "strings" when
they are actually bytes.

Fixes python#101021
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 14, 2023
miss-islington added a commit that referenced this issue Jan 14, 2023
(cherry picked from commit 49cae39)

Co-authored-by: Bob Kline <[email protected]>
warsaw added a commit that referenced this issue Jan 15, 2023
…101052)

(cherry picked from commit 49cae39)

Co-authored-by: Bob Kline <[email protected]>

Co-authored-by: Bob Kline <[email protected]>
@warsaw warsaw self-assigned this Jan 15, 2023
bkline added a commit to NCIOCPL/cdr-lib that referenced this issue Jan 18, 2023
The documentation for the email class was misleading (see bug
report python/cpython#101021), and
could be read as implying that the argument to the MIME...()
constructors should be bytes, but that's not right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-email
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants