]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-105587: Remove assertion from `_PyStaticObject_CheckRefcnt` (GH-105638...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 14 Jun 2023 05:04:22 +0000 (22:04 -0700)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 05:04:22 +0000 (05:04 +0000)
gh-105587: Remove assertion from `_PyStaticObject_CheckRefcnt` (GH-105638)
(cherry picked from commit 6199fe3b3236748033a7ce2559aeddb5a91bbbd9)

Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
Include/internal/pycore_global_objects_fini_generated.h
Misc/NEWS.d/next/Core and Builtins/2023-06-10-21-38-49.gh-issue-105587.rL3rzv.rst [new file with mode: 0644]

index d5819fcd1c50383e134f5fbde4fb88236c220a90..439f47a263dfa1cb582165789a75c59f5d76f49c 100644 (file)
@@ -12,9 +12,8 @@ extern "C" {
 static inline void
 _PyStaticObject_CheckRefcnt(PyObject *obj) {
     if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) {
-        _PyObject_ASSERT_FAILED_MSG(obj,
-            "immortal object has less refcnt than expected "
-            "_Py_IMMORTAL_REFCNT");
+        fprintf(stderr, "Immortal Object has less refcnt than expected.\n");
+        _PyObject_Dump(obj);
     }
 }
 #endif
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-06-10-21-38-49.gh-issue-105587.rL3rzv.rst b/Misc/NEWS.d/next/Core and Builtins/2023-06-10-21-38-49.gh-issue-105587.rL3rzv.rst
new file mode 100644 (file)
index 0000000..488f82c
--- /dev/null
@@ -0,0 +1,3 @@
+The runtime can't guarantee that immortal objects will not be mutated by
+Extensions. Thus, this modifies _PyStaticObject_CheckRefcnt to warn
+instead of asserting.