[issue39500] Document PyUnicode_IsIdentifier() function

Serhiy Storchaka report at bugs.python.org
Thu Jan 30 05:13:55 EST 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Since the behavior was changed, I think we need a versionchanged directive.

This function was added in 3.0. Prior to 3.3 it was always successful (if you pass an unicode object, that is required for most of PyUnicode API). Py_FatalError was added in 3.3, because not all unicode object are now valid. But I am not sure that it could be triggered in real code without using some broken extensions.

It may be safer to return 0 instead of returning -1 or crashing if PyUnicode_READY() fails. If return -1 and set an exception, it can lead to an unexpected behavior if the calling code expects only 0/1, and maybe even to crash in debug build due to set an exception and returning value.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39500>
_______________________________________


More information about the Python-bugs-list mailing list