Skip to content

Commit 19d64f0

Browse files
committed
Remove check on small ints in long_dealloc
1 parent 9dabace commit 19d64f0

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

Objects/longobject.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,20 +3614,10 @@ long_richcompare(PyObject *self, PyObject *other, int op)
36143614
static void
36153615
long_dealloc(PyObject *self)
36163616
{
3617-
/* This should never get called, but we also don't want to SEGV if
3618-
* we accidentally decref small Ints out of existence. Instead,
3619-
* since small Ints are immortal, re-set the reference count.
3620-
*/
36213617
PyLongObject *pylong = (PyLongObject*)self;
3622-
if (pylong && _PyLong_IsCompact(pylong)) {
3623-
stwodigits ival = medium_value(pylong);
3624-
if (IS_SMALL_INT(ival)) {
3625-
PyLongObject *small_pylong = (PyLongObject *)get_small_int((sdigit)ival);
3626-
if (pylong == small_pylong) {
3627-
_Py_SetImmortal(self);
3628-
return;
3629-
}
3630-
}
3618+
if (_PyLong_IsCompact(pylong)) {
3619+
// assert the small ints are not deallocated
3620+
assert (!(PyLong_CheckExact(self) && IS_SMALL_INT(medium_value(pylong))));
36313621
}
36323622
Py_TYPE(self)->tp_free(self);
36333623
}

0 commit comments

Comments
 (0)