GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-142214: Fix two regressions in dataclasses by JelleZijlstra · Pull Request #142223 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Dec 3, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Dataclasses without __init__ no longer work in 3.14.1 due to #137711 #142214

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JelleZijlstra added 2 commits December 3, 2025 06:12
@JelleZijlstra
pythongh-142214: Fix two regressions in dataclasses
224f4ad
@JelleZijlstra
format
5c3d789
@JelleZijlstra
JelleZijlstra requested a review from ericvsmith as a code owner December 3, 2025 14:14
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 3, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 3, 2025
Dataclasses without __init__ no longer work in 3.14.1 due to #137711 #142214
Closed
AlexWaygood
AlexWaygood reviewed Dec 3, 2025
View reviewed changes
Comment thread Lib/dataclasses.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra added 2 commits December 3, 2025 06:22
@JelleZijlstra
fix
42a6898
@JelleZijlstra
fix NEWS syntax
9a9ef90
sobolevn
sobolevn reviewed Dec 3, 2025
View reviewed changes
Comment thread Lib/dataclasses.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@DavidCEllis

DavidCEllis commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

I am kicking myself on the __annotate__ access. Honestly surprised it didn't trip any existing tests.

It looks like the sqlalchemy field issue is from replacing and subsequently attempting to restore annotations in order to add fields to a dataclass as there's no mechanism for doing so without annotations. The check to fix this is fine, I'm actually surprised I hadn't written this as a comprehension.

Again, sorry for missing these possibilities.

AlexWaygood, mabdullahsoyturk, basnijholt, and Giuzzilla reacted with heart emoji
All reactions
  • ❤️ 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra @sobolevn
Update Lib/dataclasses.py
1051d6c
Co-authored-by: sobolevn <[email protected]>
basnijholt
basnijholt approved these changes Dec 3, 2025
View reviewed changes

@basnijholt basnijholt left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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 just locally applied the changes in Lib/dataclasses.py and it fixed all the failing tests on github.com/pipefunc/pipefunc.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner and yihong0618 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@JelleZijlstra JelleZijlstra added the needs backport to 3.14 bugs and security fixes label Dec 3, 2025
@DavidCEllis DavidCEllis mentioned this pull request Dec 3, 2025
Dataclass inheritance pattern breaks with Python 3.14.1 sqlalchemy/sqlalchemy#13021
Closed
ericvsmith
ericvsmith requested changes Dec 3, 2025
View reviewed changes

@ericvsmith ericvsmith left a comment

Copy link
Copy Markdown
Member

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.

A small nit, but otherwise looks good to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/dataclasses.py
# gh-142214: The annotation may be missing in unusual dynamic cases.
# If so, just skip it.
if k in cls_annotations:
new_annotations[k] = cls_annotations[k]

@ericvsmith ericvsmith Dec 3, 2025

Copy link
Copy Markdown
Member

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.

Don't in and [] both do a lookup? Maybe it would be better as:

if ann := cls_annotations.get(k):
    new_annotations[k] = ann

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DavidCEllis DavidCEllis Dec 3, 2025

Copy link
Copy Markdown
Contributor

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 believe that None is a valid annotation here so this would miss None values?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Dec 3, 2025

Copy link
Copy Markdown
Member Author

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.

Correct. To save a lookup we could do a try-except KeyError instead. I don't have a preference but I can switch to that if you like.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DavidCEllis DavidCEllis Dec 3, 2025

Copy link
Copy Markdown
Contributor

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 think try/except makes sense as in most cases the key should be there. The key not being there should only be in cases where something has modified annotations and removed things after the class has been processed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ericvsmith reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@JelleZijlstra JelleZijlstra Dec 4, 2025

Copy link
Copy Markdown
Member Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot removed the awaiting core review label Dec 3, 2025
@bedevere-app

bedevere-app Bot commented Dec 3, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Dec 3, 2025
@hugovk hugovk mentioned this pull request Dec 4, 2025
Bug in 3.14.1 Release: Dataclass triggers exception when init=False and slots=True #142251
Closed
JelleZijlstra added 2 commits December 4, 2025 11:50
@JelleZijlstra
try except
320d804
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into fixdatacl
bbbe84d
@JelleZijlstra

JelleZijlstra commented Dec 4, 2025

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Dec 4, 2025
@bedevere-app

bedevere-app Bot commented Dec 4, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@ericvsmith: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from ericvsmith December 4, 2025 19:50
@mweinelt mweinelt mentioned this pull request Dec 5, 2025
python313: 3.13.9 -> 3.13.10; python314: 3.14.0 -> 3.14.1 NixOS/nixpkgs#467410
Merged
4 of 13 tasks
ericvsmith
ericvsmith approved these changes Dec 5, 2025
View reviewed changes

@ericvsmith ericvsmith left a comment

Copy link
Copy Markdown
Member

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.

Looks good to me. Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk and AlexWaygood reacted with rocket emoji
All reactions
  • 🚀 2 reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Dec 5, 2025
@JelleZijlstra
JelleZijlstra merged commit 53ec7c8 into python:main Dec 5, 2025
51 of 54 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 5, 2025
@miss-islington-app

miss-islington-app Bot commented Dec 5, 2025

Copy link
Copy Markdown

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

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 Dec 5, 2025
@JelleZijlstra @miss-islington
pythongh-142214: Fix two regressions in dataclasses (pythonGH-142223)
498e477
(cherry picked from commit 53ec7c8)

Co-authored-by: Jelle Zijlstra <[email protected]>
@bedevere-app

bedevere-app Bot commented Dec 5, 2025

Copy link
Copy Markdown

GH-142277 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Dec 5, 2025
@JelleZijlstra
JelleZijlstra deleted the fixdatacl branch December 5, 2025 04:06
JelleZijlstra added a commit that referenced this pull request Dec 5, 2025
@miss-islington @JelleZijlstra
[3.14] gh-142214: Fix two regressions in dataclasses (GH-142223) (#14…
654e3c7
…2277)

gh-142214: Fix two regressions in dataclasses (GH-142223)
(cherry picked from commit 53ec7c8)

Co-authored-by: Jelle Zijlstra <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@JelleZijlstra @StanFromIreland
pythongh-142214: Fix two regressions in dataclasses (python#142223)
3265f88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn left review comments
@DavidCEllis DavidCEllis DavidCEllis left review comments
@AlexWaygood AlexWaygood AlexWaygood left review comments
@ericvsmith ericvsmith ericvsmith approved these changes
+1 more reviewer
@basnijholt basnijholt basnijholt approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

6 participants

@JelleZijlstra @DavidCEllis @ericvsmith @sobolevn @basnijholt @AlexWaygood
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.