Skip to content

Commit df6ea14

Browse files
Another flag on immortal
1 parent 5d2eb98 commit df6ea14

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Include/internal/pycore_stackref.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,12 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj)
502502
assert(obj != NULL);
503503
// Make sure we don't take an already tagged value.
504504
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
505-
return (_PyStackRef){ .bits = (uintptr_t)obj };
505+
if (_Py_IsImmortal(obj)) {
506+
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
507+
}
508+
else {
509+
return (_PyStackRef){ .bits = (uintptr_t)obj };
510+
}
506511
}
507512
# define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj))
508513

@@ -542,7 +547,7 @@ PyStackRef_FromPyObjectNew(PyObject *obj)
542547
// Make sure we don't take an already tagged value.
543548
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
544549
assert(obj != NULL);
545-
if (_PyObject_HasDeferredRefcount(obj)) {
550+
if (_PyObject_HasDeferredRefcount(obj) || _Py_IsImmortal(obj)) {
546551
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
547552
}
548553
else {

0 commit comments

Comments
 (0)