Visitar URL original
gh-101266: Fix __sizeof__ for subclasses of int by mdickinson · Pull Request #101394 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20230130171321/https://github.com/python/cpython/pull/101394
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-101266: Fix __sizeof__ for subclasses of int #101394

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Jan 28, 2023 •

This PR fixes the behaviour of the __sizeof__ method (and hence the results returned by sys.getsizeof) for subclasses of int.

@mdickinson
Copy link
Member Author

@ionite34 This should fix the int portion of the bug you reported.

@corona10 Do you have enough spare cycles to review?

@mdickinson mdickinson requested a review from corona10 Jan 28, 2023
@mdickinson
Copy link
Member Author

Darnit; this fails for bool; looks like we'll have to special case in boolobject.c. Working on it.

@mdickinson mdickinson marked this pull request as draft Jan 28, 2023
@mdickinson
Copy link
Member Author

this fails for bool

That's because we had somewhat bogus numbers for tp_basicsize and tp_itemsize for the bool class. Now fixed.

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 __sizeof__ implementation for bool in that case, and it doesn't seem worth the effort.

@corona10
Copy link
Member

Do you have enough spare cycles to review?

Thanks I will take a look

@mdickinson mdickinson marked this pull request as ready for review Jan 28, 2023
@corona10 corona10 self-assigned this Jan 29, 2023
@corona10
Copy link
Member

@mdickinson We have to resolve the conflict before reviewing this PR.
Mark Shannon refactored the longobject ;)
c1b1f51

@corona10 corona10 added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 30, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @corona10 for commit 9cd5d01 🤖

If you want to schedule another build, you need to add the :hammer: test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants