Skip to content

Commit 56509f4

Browse files
committed
Add some asserts
1 parent 3b25dc3 commit 56509f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Include/refcount.h

+4
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static inline void Py_DECREF_MORTAL(const char *filename, int lineno, PyObject *
390390
_Py_NegativeRefcount(filename, lineno, op);
391391
}
392392
_Py_DECREF_STAT_INC();
393+
assert(!_Py_IsStaticImmortal(op));
393394
if (!_Py_IsImmortal(op)) {
394395
_Py_DECREF_DecRefTotal();
395396
}
@@ -407,6 +408,7 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
407408
_Py_NegativeRefcount(filename, lineno, op);
408409
}
409410
_Py_DECREF_STAT_INC();
411+
assert(!_Py_IsStaticImmortal(op));
410412
if (!_Py_IsImmortal(op)) {
411413
_Py_DECREF_DecRefTotal();
412414
}
@@ -442,6 +444,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
442444
#else
443445
static inline void Py_DECREF_MORTAL(PyObject *op)
444446
{
447+
assert(!_Py_IsStaticImmortal(op));
445448
_Py_DECREF_STAT_INC();
446449
if (--op->ob_refcnt == 0) {
447450
_Py_Dealloc(op);
@@ -451,6 +454,7 @@ static inline void Py_DECREF_MORTAL(PyObject *op)
451454

452455
static inline void Py_DECREF_MORTAL_SPECIALIZED(PyObject *op, destructor destruct)
453456
{
457+
assert(!_Py_IsStaticImmortal(op));
454458
_Py_DECREF_STAT_INC();
455459
if (--op->ob_refcnt == 0) {
456460
destruct(op);

0 commit comments

Comments
 (0)