Does not decref boolean constants (#57268)

TRUE/FALSE are special references in CPython bindings whose reference
count must never be updated.
This commit is contained in:
Benjamin Dauvergne 2021-09-27 14:14:23 +02:00
parent d80357e226
commit a28fb8c8e1
1 changed files with 2 additions and 1 deletions

View File

@ -728,7 +728,8 @@ register_constants(PyObject *d)
else:
print_('E: unknown constant type: %r' % c[0], file=sys.stderr)
print_(' PyDict_SetItemString(d, "%s", obj);' % c[1][6:], file=fd)
print_(' Py_DECREF(obj);', file=fd)
if c[0] != 'b': # refcount of Py_True/False should not be changed
print_(' Py_DECREF(obj);', file=fd)
print_('}', file=fd)
print_('', file=fd)