gh-101266: Fix __sizeof__ for subclasses of int#101394
gh-101266: Fix __sizeof__ for subclasses of int#101394mdickinson merged 7 commits intopython:mainfrom
Conversation
|
Darnit; this fails for |
That's because we had somewhat bogus numbers for I'm going to remove the "backport to 3.10" label: the bug does technically still exist in 3.10, but it's messier to fix - it looks like we would need to add a dedicated |
Thanks I will take a look |
|
@mdickinson We have to resolve the conflict before reviewing this PR. |
Thanks! Updated. |
corona10
left a comment
There was a problem hiding this comment.
lgtm,
Just one more thing,
Would you like to change the PyBool_Type initialization with C99 style through this chance?
PyTypeObject PyBool_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"bool",
.tp_basicsize = offsetof(struct _longobject, long_value.ob_digit),
.tp_itemsize = sizeof(digit),
.tp_dealloc = bool_dealloc,
...
.tp_vectorcall = bool_vectorcall
Good idea! It may make sense to do that in a separate PR, though: I was hoping to backport this bugfix PR to 3.11, and the C99 style change sounds like a cosmetic update that shouldn't be backported. |
Great! Feel free to merge anytime you want :) |
|
Thanks @mdickinson for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
|
Sorry, @mdickinson, I could not cleanly backport this to |
|
Hmm. Looks like I'll need to do a manual cherry-pick backport to 3.11, excluding the last few commits. I'll do that later today. |
|
GH-101579 is a backport of this pull request to the 3.11 branch. |
|
See #101579 for a manual backport to 3.11 (cherry-picking the commits up to but excluding the |
…101579) Fix the behaviour of the `__sizeof__` method (and hence the results returned by `sys.getsizeof`) for subclasses of `int`. Previously, `int` subclasses gave identical results to the `int` base class, ignoring the presence of the instance dictionary. (Manual backport of #101394 to the Python 3.11 branch.)
…ythonGH-101394) (python#101579)" This reverts commit cf89c16.
|
This PR was the first one to fail refleak bot ( See #101766 |
|
Hmm. We could try reverting it in a PR, and then running the refleak buildbots on that PR to see what happens. It seems rather implausible that it was this particular PR that introduced the refleak, though. |
|
Yes, seems suspicious. I will investigate! |
This PR fixes the behaviour of the
__sizeof__method (and hence the results returned bysys.getsizeof) for subclasses ofint.intandsetsubclass__sizeof__under-reports the instance dictionary pointer #101266