|
6 | 6 | #include "pycore_bitutils.h" // _Py_popcount32() |
7 | 7 | #include "pycore_initconfig.h" // _PyStatus_OK() |
8 | 8 | #include "pycore_call.h" // _PyObject_MakeTpCall |
9 | | -#include "pycore_freelist.h" // _Py_FREELIST_FREE(), _Py_FREELIST_POP() |
| 9 | +#include "pycore_freelist.h" // _Py_FREELIST_FREE, _Py_FREELIST_POP |
10 | 10 | #include "pycore_long.h" // _Py_SmallInts |
11 | 11 | #include "pycore_object.h" // _PyObject_Init() |
12 | 12 | #include "pycore_runtime.h" // _PY_NSMALLPOSINTS |
@@ -43,7 +43,7 @@ static inline void |
43 | 43 | _Py_DECREF_INT(PyLongObject *op) |
44 | 44 | { |
45 | 45 | assert(PyLong_CheckExact(op)); |
46 | | - _Py_DECREF_SPECIALIZED((PyObject *)op, (destructor) _PyLong_ExactDealloc); |
| 46 | + _Py_DECREF_SPECIALIZED((PyObject *)op, _PyLong_ExactDealloc); |
47 | 47 | } |
48 | 48 |
|
49 | 49 | static inline int |
@@ -3631,26 +3631,24 @@ static void |
3631 | 3631 | long_dealloc(PyObject *self) |
3632 | 3632 | { |
3633 | 3633 | PyLongObject *pylong = (PyLongObject*)self; |
| 3634 | + assert(pylong); |
3634 | 3635 |
|
3635 | | - if (pylong && _PyLong_IsCompact(pylong)) { |
| 3636 | + if (_PyLong_IsCompact(pylong)) { |
3636 | 3637 | stwodigits ival = medium_value(pylong); |
3637 | 3638 | if (IS_SMALL_INT(ival)) { |
3638 | 3639 | PyLongObject *small_pylong = (PyLongObject *)get_small_int((sdigit)ival); |
3639 | 3640 | if (pylong == small_pylong) { |
3640 | 3641 | /* This should never get called, but we also don't want to SEGV if |
3641 | | - * we accidentally decref small Ints out of existence. Instead, |
3642 | | - * since small Ints are immortal, re-set the reference count. |
3643 | | - */ |
3644 | | - // can we remove the next two lines? the immortal objects now have a fixed refcount |
3645 | | - // in particular in the free-threading build this seeems safe |
| 3642 | + * we accidentally decref small Ints out of existence. Instead, |
| 3643 | + * since small Ints are immortal, re-set the reference count. |
| 3644 | + * |
| 3645 | + * With a fixed refcount for immortal objects this should not happen |
| 3646 | + */ |
3646 | 3647 | _Py_SetImmortal(self); |
3647 | 3648 | return; |
3648 | 3649 | } |
3649 | 3650 | } |
3650 | | - } |
3651 | | - |
3652 | | - if (PyLong_CheckExact(self)) { |
3653 | | - if (_PyLong_IsCompact((PyLongObject *)self)) { |
| 3651 | + if (PyLong_CheckExact(self)) { |
3654 | 3652 | _Py_FREELIST_FREE(ints, self, PyObject_Free); |
3655 | 3653 | return; |
3656 | 3654 | } |
@@ -6642,7 +6640,7 @@ PyTypeObject PyLong_Type = { |
6642 | 6640 | 0, /* tp_init */ |
6643 | 6641 | 0, /* tp_alloc */ |
6644 | 6642 | long_new, /* tp_new */ |
6645 | | - (freefunc)PyObject_Free, /* tp_free */ |
| 6643 | + PyObject_Free, /* tp_free */ |
6646 | 6644 | .tp_vectorcall = long_vectorcall, |
6647 | 6645 | .tp_version_tag = _Py_TYPE_VERSION_INT, |
6648 | 6646 | }; |
|
0 commit comments