[New-bugs-announce] [issue42684] Improvements to documentation for PyUnicode_FS{Converter, Decoder}
Antony Lee
report at bugs.python.org
Sat Dec 19 07:51:17 EST 2020
New submission from Antony Lee <anntzer.lee at gmail.com>:
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.
----------
assignee: docs at python
components: C API, Documentation
messages: 383378
nosy: Antony.Lee, docs at python
priority: normal
severity: normal
status: open
title: Improvements to documentation for PyUnicode_FS{Converter,Decoder}
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42684>
_______________________________________
More information about the New-bugs-announce
mailing list