mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-101266: Revert fix __sizeof__ for subclasses of int (#101638)
Revert "[3.11] gh-101266: Fix __sizeof__ for subclasses of int (GH-101394) (#101579)"
This reverts commit cf89c16486
.
This commit is contained in:
parent
c993ffa477
commit
358b02dac4
4 changed files with 9 additions and 48 deletions
|
@ -5664,10 +5664,13 @@ static Py_ssize_t
|
|||
int___sizeof___impl(PyObject *self)
|
||||
/*[clinic end generated code: output=3303f008eaa6a0a5 input=9b51620c76fc4507]*/
|
||||
{
|
||||
/* using Py_MAX(..., 1) because we always allocate space for at least
|
||||
one digit, even though the integer zero has a Py_SIZE of 0 */
|
||||
Py_ssize_t ndigits = Py_MAX(Py_ABS(Py_SIZE(self)), 1);
|
||||
return Py_TYPE(self)->tp_basicsize + Py_TYPE(self)->tp_itemsize * ndigits;
|
||||
Py_ssize_t res;
|
||||
|
||||
res = offsetof(PyLongObject, ob_digit)
|
||||
/* using Py_MAX(..., 1) because we always allocate space for at least
|
||||
one digit, even though the integer zero has a Py_SIZE of 0 */
|
||||
+ Py_MAX(Py_ABS(Py_SIZE(self)), 1)*sizeof(digit);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue