From 0124b5dd28eff7bb80eb7244e97e402a036db13b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 9 Nov 2022 08:40:40 +0100 Subject: 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. --- Tools/build/generate_global_objects.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Tools/build/generate_global_objects.py') diff --git a/Tools/build/generate_global_objects.py b/Tools/build/generate_global_objects.py index 5516dcf93a..c7a07180fa 100644 --- a/Tools/build/generate_global_objects.py +++ b/Tools/build/generate_global_objects.py @@ -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) -- cgit v1.2.1