This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Documentation for email.charset confusing about the location of constants
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python,, r.david.murray
Priority: normal Keywords:

Created on 2018-05-09 17:38 by Francois Labelle, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg316327 - (view) Author: Francois Labelle (Francois Labelle) Date: 2018-05-09 17:38
When mentioning the constants contained in the module email.charset, the documentation prefixes them with "Charset", for example: Charset.QP, Charset.BASE64, Charset.SHORTEST. This suggests that the constants can be found on the class "Charset" (uppercase first letter) in the module, while they are in fact contained in the the "charset" (lowercase first letter) module itself.

This is probably a left-over from when the module was called email.Charset (in 2.2 I believe). Under Python 2.7, while the documentation uses the same nomenclature, at least the module is also importable under the name email.Charset so it makes more sense.
msg316364 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-10 14:06
Can you provide an example of where this occurs in the docs?
msg316374 - (view) Author: Francois Labelle ( Date: 2018-05-10 20:20
Original poster here (OpenID just wouldn't work anymore).

For instance:

Under "class email.charset.Charset"

Under "header_encoding"

"If the character set must be encoded before it can be used in an email header, this attribute will be set to Charset.QP (for quoted-printable), Charset.BASE64 (for base64 encoding), or Charset.SHORTEST for the shortest of QP or BASE64 encoding. Otherwise, it will be None."
msg316378 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-10 21:17
Ah, I see.  Yes, those strings are actually hardcoded in the documentation source instead of being references.  You are correct, they should be fixed.  Note, however, that Charset is part of the legacy API and isn't actually used if you use the new API in python3.
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77630
2021-12-19 00:41:56AlexWaygoodsetversions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.7, Python 3.8
2018-05-10 21:17:45r.david.murraysettype: enhancement -> behavior
stage: needs patch
messages: + msg316378
versions: - Python 3.4, Python 3.5, Python 3.6
2018-05-10 20:20:07quantum.omegasetnosy: +, - Francois Labelle
messages: + msg316374
2018-05-10 14:06:37r.david.murraysetnosy: + r.david.murray
messages: + msg316364
2018-05-09 17:38:58Francois Labellecreate