-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
struct.Struct inheritance with Python 3.12.0 #112358
Comments
bisected to c8c0afc |
Looks like another user also hit this problem, but reported it on the PR rather than opening an issue: #94532 (comment) |
Hmm, this isn't nice. I'm not seeing any good options here other than simply reverting the offending commit (and re-opening the issues that PR #94532 was supposed to close). @kumaraditya303? |
To elaborate: the existence of This makes the solution in #94532 of initialising the struct in I've opened #112424 for reversion. Once merged, it'll need to be backported to 3.12, and issues #75960 and #78724 will need to be re-opened. |
…truct.Struct. (pythonGH-112424) Revert commit c8c0afc (PR pythonGH-94532), which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`. This caused issues with code in the wild that subclasses `struct.Struct`.. (cherry picked from commit 9fe6034) Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
…Struct (GH-112424) (#112426) * [3.12] gh-112358: Fix Python 3.12 regression with subclassing struct.Struct. (GH-112424) Revert commit c8c0afc (PR GH-94532), which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`. This caused issues with code in the wild that subclasses `struct.Struct`.. (cherry picked from commit 9fe6034) Co-authored-by: Mark Dickinson <dickinsm@gmail.com> * Remove unrelated test
It is more convenient to initialize the Struct instance in Can this breakage be considered a lesser evil? |
@serhiy-storchaka: Maybe. I'd failed to recognise the scope of the breakage introduced by #94532, and I think reverting in the short term is the right solution. Longer term, if we can find a properly deprecated path to moving the initialisation to For the particular issues that #94532 was addressing, I think there are likely less disruptive fixes available. |
…truct. (python#112424) Revert commit c8c0afc (PR python#94532), which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`. This caused issues with code in the wild that subclasses `struct.Struct`.
…truct. (python#112424) Revert commit c8c0afc (PR python#94532), which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`. This caused issues with code in the wild that subclasses `struct.Struct`.
Bug report
Bug description:
When I run this code I receive an error:
It is rather strange error, I have passed
format
parameter to base class constructor, I receive this error with any value offormat
parameter.There are no any problems with this code in Python 3.11 and older.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: