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.

Author Antony.Lee
Recipients Antony.Lee, docs@python
Date 2020-12-19.12:51:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608382277.1.0.605007079577.issue42684@roundup.psfhosted.org>
In-reply-to
Content
The docs for PyUnicode_FSConverter and PyUnicode_FSDecoder could be improved on two points:

- The functions also reject str/bytes that contain null bytes (one can easily verify that there's a specific check for them in the C implementations).  Currently the docs only say that the converters use PyUnicode_EncodeFSDefault/PyUnicode_DecodeFSDefaultAndSize, but those don't check for null bytes.

- The functions only ever return 1 or 0 (indicating success or failures), which means that one can just use e.g. `if (!PyUnicode_FSConverter(foo, &bar)) { goto error; } ...` (this pattern occurs repeatedly in the CPython codebase).  In theory, given that the functions are only documented as being "O&"-converters, they could also be returning Py_CLEANUP_SUPPORTED in which case they'd need to be called a second time on failure to release allocated memory.
History
Date User Action Args
2020-12-19 12:51:17Antony.Leesetrecipients: + Antony.Lee, docs@python
2020-12-19 12:51:17Antony.Leesetmessageid: <1608382277.1.0.605007079577.issue42684@roundup.psfhosted.org>
2020-12-19 12:51:17Antony.Leelinkissue42684 messages
2020-12-19 12:51:16Antony.Leecreate