mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
gh-90868: Add _PyStaticObject_CheckRefcnt() function (#99261)
Add _PyStaticObject_CheckRefcnt() function to make _PyStaticObjects_CheckRefcnt() shorter. Use _PyObject_ASSERT_FAILED_MSG() to log the object causing the fatal error.
This commit is contained in:
parent
f7a82cde59
commit
0124b5dd28
2 changed files with 1458 additions and 5782 deletions
|
@ -388,11 +388,8 @@ def generate_global_object_finalizers(immortal_objects):
|
|||
printer.write("static inline void")
|
||||
with printer.block("_PyStaticObjects_CheckRefcnt(void)"):
|
||||
for i in immortal_objects:
|
||||
with printer.block(f'if (Py_REFCNT({i}) < _PyObject_IMMORTAL_REFCNT)', ';'):
|
||||
printer.write(f'_PyObject_Dump({i});')
|
||||
printer.write(f'Py_FatalError("immortal object has less refcnt than '
|
||||
'expected _PyObject_IMMORTAL_REFCNT");')
|
||||
printer.write('#endif')
|
||||
printer.write(f'_PyStaticObject_CheckRefcnt({i});')
|
||||
printer.write('#endif // Py_DEBUG')
|
||||
printer.write(END)
|
||||
printer.write(after)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue