[issue29369] Use Py_IDENTIFIER in Python-ast.c

STINNER Victor report at bugs.python.org
Wed Jan 25 09:58:45 EST 2017


STINNER Victor added the comment:

+    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOO}",
+                    type, base,
+                    _PyUnicode_FromId(&PyId__fields), fnames,
+                    _PyUnicode_FromId(&PyId___module__),
+                    _PyUnicode_FromId(&PyId__ast));

You should check if _PyUnicode_FromId() returns NULL if it was the first call and the UTF-8 decode failed to allocate memory.

You might initialize all these identifiers (and check for errors) in init_types() to avoid having to check for errors each time they are used.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29369>
_______________________________________


More information about the Python-bugs-list mailing list