Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rewrite assert
  • Loading branch information
eendebakpt committed Nov 22, 2024
commit 4117c549dc250a1ea23408145f5190b08856e6ac
22 changes: 17 additions & 5 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3611,14 +3611,26 @@ long_richcompare(PyObject *self, PyObject *other, int op)
Py_RETURN_RICHCOMPARE(result, 0, op);
}

static int _is_python_smallint(PyObject *op)
{
PyLongObject *pylong = (PyLongObject*)op;
if (pylong && _PyLong_IsCompact(pylong)) {
stwodigits ival = medium_value(pylong);
if (IS_SMALL_INT(ival)) {
PyLongObject *small_pylong = (PyLongObject *)get_small_int((sdigit)ival);
if (pylong == small_pylong) {
return 1;
}
}
}
return 0;
}

static void
Comment thread
ZeroIntensity marked this conversation as resolved.
long_dealloc(PyObject *self)
{
PyLongObject *pylong = (PyLongObject*)self;
if (_PyLong_IsCompact(pylong)) {
// assert the small ints are not deallocated
assert (!(PyLong_CheckExact(self) && IS_SMALL_INT(medium_value(pylong))));
}
// assert the small ints are not deallocated
assert(!_is_python_smallint(self));
Comment thread
ZeroIntensity marked this conversation as resolved.
Outdated
Py_TYPE(self)->tp_free(self);
}

Expand Down