bpo-33601: Document for Py_UTF8Mode by y43ren · Pull Request #7143 · python/cpython (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is incorrect. Extract of Python/bltinmodule.c:
/* UTF-8 mode (PEP 540): if equals to 1, use the UTF-8 encoding, and change
stdin and stdout error handler to "surrogateescape". It is equal to
-1 by default: unknown, will be set by Py_Main() */
int Py_UTF8Mode = -1;
I suggest:
- If set to 1, enable the UTF-8 Mode
- If set to 0, disable the UTF-8 Mode
- If set to -1, look for the :envvar:
PYTHONUTF8
environment variable and the :option:-X
utf8
command line option
I would suggest to not document here the effects of the UTF-8 Mode.
Currently, the effects of the UTF-8 Mode are not documented. But I would prefer to not document it at 3 different places: C API doc, PYTHONUTF8 doc, -X utf8 doc.
I don't know what is the best place to document the UTF-8 Mode, but I would prefer to document it in a Python documentation (not in the C API).