GeezerVison is showing github.com — gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) by JelleZijlstra · Pull Request #137047 · python/cpython
Conversation
JelleZijlstra
commented
Jul 23, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This is a redo of #136893 without relying on a hack to get to the type dictionary.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ke the original class collectible (python#136893)
An interesting hack, but more localized in scope than python#135230.
This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.
Co-authored-by: Alyssa Coghlan <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check that this is a Python class? Should we clear the whole class dict or set it to NULL for the case if there are more descriptors?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Can we check that this is a Python class?
Maybe we can check that it's a heap type?
Should we clear the whole class dict or set it to NULL for the case if there are more descriptors?
I'm not aware of other descriptors that could cause problems. It's better to minimize the amount of changes we make to the class, because there are edge cases where the class is still accessible after the dataclass transformation is applied.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find any issues in the PR; this is pretty much is the local optimum.
But, I can't tell if there will be unintended consequences. This PR feels quite risky for a RC fix.
Docs-wise: the notes/comments shouldn't imply that the original class is guaranteed to be garbage collected -- something else could still keep it alive.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
@hugovk Your thoughts on this?
IMO: If we weren't in RC period, I'd push for #136966, which is IMO a (slight) improvement on its own. But, it has a higher risk of unknown unknowns.
For backporting to 3.14.0, this dataclasses-specific workaround is probably better. But, all of it is a band-aid.
|
serhiy-storchaka reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @encukou. #136966 may be better in long perspective (or it may be a move in right direction), but this change has more limited impact, and therefore lokks safer. We always can backport #136966 if we test it well.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
I also agree that #136966 is a better long-term solution; we can merge it into 3.15 after this goes in, and we can also consider using it in 3.14.1.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @JelleZijlstra for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Aug 12, 2025
…ke the original class collectible (take 2) (pythonGH-137047)
Remove the `__dict__` and `__weakref__` descriptors from the original class when creating a dataclass from it.
An interesting hack, but more localized in scope than pythongh-135230.
This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.
(cherry picked from commit 6859b95)
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alyssa Coghlan <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hugovk
commented
Aug 12, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks all, let's do this fix for RC2 -- I'll merge the backport #137666 once tests pass and it's approved.
And do #136966 for 3.15 and possibly 3.14.1.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot aarch64 Fedora Stable LTO + PGO 3.x (tier-2) has failed when building commit 6859b95.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/524/builds/8141) and take a look at the build logs.
- Check if the failure is related to this commit (6859b95) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/#/builders/524/builds/8141
Summary of the results of the build (if available):
Click to see traceback logs
remote: Enumerating objects: 14, done.
remote: Counting objects: 9% (1/11)
remote: Counting objects: 18% (2/11)
remote: Counting objects: 27% (3/11)
remote: Counting objects: 36% (4/11)
remote: Counting objects: 45% (5/11)
remote: Counting objects: 54% (6/11)
remote: Counting objects: 63% (7/11)
remote: Counting objects: 72% (8/11)
remote: Counting objects: 81% (9/11)
remote: Counting objects: 90% (10/11)
remote: Counting objects: 100% (11/11)
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 11% (1/9)
remote: Compressing objects: 22% (2/9)
remote: Compressing objects: 33% (3/9)
remote: Compressing objects: 44% (4/9)
remote: Compressing objects: 55% (5/9)
remote: Compressing objects: 66% (6/9)
remote: Compressing objects: 77% (7/9)
remote: Compressing objects: 88% (8/9)
remote: Compressing objects: 100% (9/9)
remote: Compressing objects: 100% (9/9), done.
remote: Total 14 (delta 2), reused 2 (delta 2), pack-reused 3 (from 1)
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to '6859b95cfff26c9ef52c5535d2b3662f17ff5b3d'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 6859b95cfff gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047)
Switched to and reset branch 'main'
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
make[2]: [Makefile:3379: clean-retain-profile] Error 1 (ignored)
Python/ceval.c: In function ‘_PyEvalFramePushAndInit_Ex’:
Python/ceval.c:1917:38: warning: ‘stack_array’ may be used uninitialized [-Wmaybe-uninitialized]
1917 | _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
| ^~~~~~~~~~~~~~~~~~~~~~~~
1918 | tstate, func, locals,
| ~~~~~~~~~~~~~~~~~~~~~
1919 | newargs, nargs, kwnames, previous
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1920 | );
| ~
Python/ceval.c:1840:1: note: by argument 4 of type ‘const union _PyStackRef *’ to ‘_PyEvalFramePushAndInit’ declared here
1840 | _PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
| ^~~~~~~~~~~~~~~~~~~~~~~
Python/ceval.c:1886:17: note: ‘stack_array’ declared here
1886 | _PyStackRef stack_array[8];
| ^~~~~~~~~~~
/usr/bin/ld: error in /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o)(.eh_frame); no .eh_frame_hdr table will be created
/usr/bin/ld: error in /usr/lib/gcc/aarch64-redhat-linux/15/libgcc.a(sync-cache.o)(.eh_frame); no .eh_frame_hdr table will be created
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 1090522845 >= 662 for section `.strtab'
/usr/bin/ld: /usr/lib/gcc/aarch64-redhat-linux/15/libgcov.a(_gcov.o): invalid string offset 3236147 >= 662 for section `.strtab'
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make[2]: *** [Makefile:1146: python] Error 1
make[1]: *** [Makefile:1005: profile-gen-stamp] Error 2
make: *** [Makefile:1017: profile-run-stamp] Error 2
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Same buildbot passed on the backport:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
encukou
added a commit
that referenced
this pull request
Aug 18, 2025
…-136966)
This partially reverts #137047, keeping the tests for GC collectability of the
original class that dataclass adds `__slots__` to.
The reference leaks solved there are instead solved by having the `__dict__` &
`__weakref__` descriptors not tied to (and referencing) their class.
Instead, they're shared between all classes that need them (within
an interpreter).
The `__objclass__` ol the descriptors is set to `object`, since these
descriptors work with *any* object. (The appropriate checks were already
made in the get/set code, so the `__objclass__` check was redundant.)
The repr of these descriptors (and any others whose `__objclass__` is `object`)
now doesn't mention the objclass.
This change required adjustment of introspection code that checks
`__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`.
Third-party code that does similar introspection of the internals will also
need adjusting.
Co-authored-by: Jelle Zijlstra <[email protected]>
Agent-Hellboy
pushed a commit
to Agent-Hellboy/cpython
that referenced
this pull request
Aug 19, 2025
…ke the original class collectible (take 2) (pythonGH-137047)
Remove the `__dict__` and `__weakref__` descriptors from the original class when creating a dataclass from it.
An interesting hack, but more localized in scope than pythongh-135230.
This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.
Co-authored-by: Alyssa Coghlan <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Agent-Hellboy
pushed a commit
to Agent-Hellboy/cpython
that referenced
this pull request
Aug 19, 2025
…ct (pythonGH-136966)
This partially reverts python#137047, keeping the tests for GC collectability of the
original class that dataclass adds `__slots__` to.
The reference leaks solved there are instead solved by having the `__dict__` &
`__weakref__` descriptors not tied to (and referencing) their class.
Instead, they're shared between all classes that need them (within
an interpreter).
The `__objclass__` ol the descriptors is set to `object`, since these
descriptors work with *any* object. (The appropriate checks were already
made in the get/set code, so the `__objclass__` check was redundant.)
The repr of these descriptors (and any others whose `__objclass__` is `object`)
now doesn't mention the objclass.
This change required adjustment of introspection code that checks
`__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`.
Third-party code that does similar introspection of the internals will also
need adjusting.
Co-authored-by: Jelle Zijlstra <[email protected]>
gpshead
added a commit
to gpshead/cpython
that referenced
this pull request
Apr 12, 2026
…_` and `__delattr__` in frozen dataclasses with slots (pythonGH-144021)
pythongh-105936: Properly update closure cells for `__setattr__` and `__delattr__` in frozen dataclasses with slots (pythonGH-144021)
(cherry picked from commit 8a398bf)
The cherry-pick required additional changes beyond the original commit
because 3.13 lacks the `__class__` closure cell fixup machinery that
was added in 3.14 by pythonGH-124455 (pythongh-90562). Specifically:
- Backported `_update_func_cell_for__class__()` helper function and the
closure fixup loop in `_add_slots()` from pythonGH-124455. Without these,
renaming the closure variable from `cls` to `__class__` has no effect
because nothing updates the cell when the class is recreated with slots.
- Changed `_add_slots()` to use `newcls` instead of reusing `cls` for the
recreated class, so both old and new class references are available for
the fixup loop.
- Replaced `assertNotHasAttr` with `assertFalse(hasattr(...))` in tests
(assertNotHasAttr was added in 3.14).
- Dropped `test_original_class_is_gced` additions (that test does not
exist on 3.13; it was added by pythonGH-137047 for pythongh-135228 which was not
backported to 3.13).
Co-authored-by: Prometheus3375 <[email protected]>
Co-authored-by: Sviataslau <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
gpshead
added a commit
that referenced
this pull request
Apr 26, 2026
…_delattr__ in frozen dataclasses with slots (GH-144021) (GH-148476)
gh-105936: Properly update closure cells for `__setattr__` and `__delattr__` in frozen dataclasses with slots (GH-144021)
(cherry picked from commit 8a398bf)
The cherry-pick required additional changes beyond the original commit
because 3.13 lacks the `__class__` closure cell fixup machinery that
was added in 3.14 by GH-124455 (gh-90562). Specifically:
- Backported `_update_func_cell_for__class__()` helper function and the
closure fixup loop in `_add_slots()` from GH-124455. Without these,
renaming the closure variable from `cls` to `__class__` has no effect
because nothing updates the cell when the class is recreated with slots.
- Changed `_add_slots()` to use `newcls` instead of reusing `cls` for the
recreated class, so both old and new class references are available for
the fixup loop.
- Replaced `assertNotHasAttr` with `assertFalse(hasattr(...))` in tests
(assertNotHasAttr was added in 3.14).
- Dropped `test_original_class_is_gced` additions (that test does not
exist on 3.13; it was added by GH-137047 for gh-135228 which was not
backported to 3.13).
gh-148947: dataclasses: fix error on empty __class__ cell (GH-148948)
Also add a test demonstrating the need for the existing "is oldcls" check.
(cherry picked from commit 6d7bbee)
---------
Co-authored-by: Prometheus3375 <[email protected]>
Co-authored-by: Sviataslau <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Bartosz Sławecki <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|