Skip to content

Commit d270553

Browse files
committed
Fix refcount accounting
1 parent 56509f4 commit d270553

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Include/internal/pycore_stackref.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static inline void PyStackRef_CheckValid(_PyStackRef ref) {
402402
case 0:
403403
case Py_TAG_REFCNT:
404404
/* Can be immortal if object was made immortal after reference came into existence */
405-
assert(obj != NULL && obj != Py_True && obj != Py_False && obj != Py_None);
405+
assert(!_Py_IsStaticImmortal(obj));
406406
break;
407407
case Py_TAG_IMMORTAL:
408408
assert(obj == NULL || _Py_IsImmortal(obj));

Include/refcount.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ static inline void Py_DECREF_MORTAL(const char *filename, int lineno, PyObject *
391391
}
392392
_Py_DECREF_STAT_INC();
393393
assert(!_Py_IsStaticImmortal(op));
394-
if (!_Py_IsImmortal(op)) {
395-
_Py_DECREF_DecRefTotal();
396-
}
394+
_Py_DECREF_DecRefTotal();
397395
if (--op->ob_refcnt == 0) {
398396
_Py_Dealloc(op);
399397
}
@@ -409,9 +407,7 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
409407
}
410408
_Py_DECREF_STAT_INC();
411409
assert(!_Py_IsStaticImmortal(op));
412-
if (!_Py_IsImmortal(op)) {
413-
_Py_DECREF_DecRefTotal();
414-
}
410+
_Py_DECREF_DecRefTotal();
415411
if (--op->ob_refcnt == 0) {
416412
destruct(op);
417413
}

0 commit comments

Comments
 (0)