summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2023-05-05 00:00:07 (GMT)
committerGitHub <noreply@github.com>2023-05-05 00:00:07 (GMT)
commitce871fdc3a02e8441ad73b13f9fced308a9d9ad1 (patch)
tree2f0cda4ab28073d7e39bbdbeda3196002d87699d /Include
parentfa86a77589a06661fcebb806d36f3a7450e2aecf (diff)
downloadcpython-ce871fdc3a02e8441ad73b13f9fced308a9d9ad1.zip
cpython-ce871fdc3a02e8441ad73b13f9fced308a9d9ad1.tar.gz
cpython-ce871fdc3a02e8441ad73b13f9fced308a9d9ad1.tar.bz2
GH-104142: Fix _Py_RefcntAdd to respect immortality (GH-104143)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_object.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index b9e700e..500b3ee 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -58,6 +58,9 @@ extern void _Py_DecRefTotal(PyInterpreterState *);
// Increment reference count by n
static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
{
+ if (_Py_IsImmortal(op)) {
+ return;
+ }
#ifdef Py_REF_DEBUG
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
#endif