Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-137600: Promoteast node constructor deprecation warnings to errors#137601

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
brianschubert wants to merge19 commits intopython:main
base:main
Choose a base branch
Loading
frombrianschubert:gh-137600-ast-constr-errors

Conversation

@brianschubert
Copy link
Member

@brianschubertbrianschubert commentedAug 9, 2025
edited by github-actionsbot
Loading

tomasr8 reacted with thumbs up emoji
@brianschubert
Copy link
MemberAuthor

@picnixz As mentioned in#121162 (comment), now that the constructors raise on missing and unknown fields, some of the checks that were added forcopy.replace support are no longer needed, so I went ahead and removed them (de5564a). Based on the tests, it looks like things are working correctly, but I'd appreciate if you could take a look to make sure I didn't break anything :-)

@brianschubertbrianschubert linked an issueAug 9, 2025 that may beclosed by this pull request
@picnixz
Copy link
Member

This takes me back as the original PR is one of my very first contributions to CPython!

brianschubert reacted with laugh emoji

@picnixzpicnixz self-requested a reviewAugust 10, 2025 06:55
Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd suggest using msg = ... + re.escape() for assertRaisesRegex() where 80 chars limit is exceeded.

brianschubertand others added2 commitsAugust 18, 2025 17:20
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@JelleZijlstra
Copy link
Member

@picnixz do you have any further feedback?

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I do not but I actually had a pending review that I started 1 month ago. They are mainly for improving coverage and wording but they are optional.

self.assertEqual(x.right,n3)

# Random attribute allowed too
x.foobarbaz=5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't know if we already cover this, but maybe we should instead:

  • Find a way to construct all nodes "correctly" or have at least one instance of each nodes.
  • For all these instances, check that we can set random attributes and delete them properly.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good idea, added a test in the style of the existingtest_field_attr_existence test.

Comment on lines 1 to 5
The constructors of node types in the:mod:`ast` module now raise a
:exc:`TypeError` when a required argument is omitted or when a
keyword argument that does not map to a field on the AST node is passed.
These cases had previously raised a:exc:`DeprecationWarning` since Python
3.13. Patch by Brian Schubert.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
The constructors of node types in the:mod:`ast` module now raise a
:exc:`TypeError` when a required argument is omitted or when a
keyword argument that does not map to a field on the AST node is passed.
These cases had previously raised a:exc:`DeprecationWarning` since Python
3.13. Patch by Brian Schubert.
:mod:`ast`: The constructors of AST nodes now raise a
:exc:`TypeError` when a required argument is omitted or when a
keyword argument that does not map to a field on the AST node is passed.
These cases had previously raised a:exc:`DeprecationWarning` since Python
3.13. Patch by Brian Schubert.

And you can reflow the paragraph as you deem fit (and also you can reuse that message in the NEWS).

brianschubert reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated, thanks!

brianschubertand others added3 commitsOctober 26, 2025 20:18
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz approved these changes

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

@Eclips4Eclips4Awaiting requested review from Eclips4Eclips4 is a code owner

@tomasr8tomasr8Awaiting requested review from tomasr8tomasr8 is a code owner

@isidenticalisidenticalAwaiting requested review from isidentical

@pablogsalpablogsalAwaiting requested review from pablogsalpablogsal is a code owner

@lysnikolaoulysnikolaouAwaiting requested review from lysnikolaoulysnikolaou is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Promoteast node constructor deprecation warnings to errors

4 participants

@brianschubert@picnixz@JelleZijlstra@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp