Skip to content

Commit f76c0e2

Browse files
committed
add assert to make sure the immortal bit is not set on subclasses
1 parent b4c8444 commit f76c0e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Objects/longobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,7 +3620,9 @@ static inline int
36203620
_long_is_small_int(PyObject *op)
36213621
{
36223622
PyLongObject *long_object = (PyLongObject *)op;
3623-
return (long_object->long_value.lv_tag & IMMORTALITY_BIT_MASK) != 0;
3623+
int is_small_int = (long_object->long_value.lv_tag & IMMORTALITY_BIT_MASK) != 0;
3624+
assert((!is_small_int) || PyLong_CheckExact(op));
3625+
return is_small_int;
36243626
}
36253627

36263628
void
@@ -3649,7 +3651,6 @@ long_dealloc(PyObject *self)
36493651
*
36503652
* See PEP 683, section Accidental De-Immortalizing for details
36513653
*/
3652-
assert(0);
36533654
_Py_SetImmortal(self);
36543655
return;
36553656
}

0 commit comments

Comments
 (0)