Skip to content

Conversation

@jepler
Copy link
Contributor

@jepler jepler commented Oct 20, 2025

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

Please see Hugo's comment on the issue, these need to raise deprecation warnings till 3.17 minimum (I don't think we need to do five years here, two should be fine).

These were all deprecated in 3.9 (bace59d) but without
a runtime deprecation warning. Add it now, so that these
items can be removed in 3.20 per PEP 387.
@jepler jepler changed the title gh-140344: ast: Remove classes deprecated since 3.9 gh-140344: ast: Add deprecation warnings Oct 20, 2025
@jepler
Copy link
Contributor Author

jepler commented Oct 20, 2025

I've updated this PR so that it makes deprecation warnings. Currently the deprecation says 3.20 is the time for removal (standard PEP 387) but I can change it to 3.17 if there's consensus that it's OK to do so.

@@ -0,0 +1,3 @@
The classes ``ast.Suite``, ``ast.AugLoad``, ``ast.AugStore``, and
Copy link
Member

Choose a reason for hiding this comment

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

This only lists four of the seven things deprecated. It also doesn't mention the .dims attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added, thanks.

indent=args.indent, show_empty=args.show_empty))

_deprecated = {
'slice': globals().pop("slice"),
Copy link
Member

Choose a reason for hiding this comment

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

Note this means from ast import * will no longer pick these up. That's probably OK for 3.15 but let's mention it in docs.

@@ -0,0 +1,3 @@
The classes ``ast.Suite``, ``ast.AugLoad``, ``ast.AugStore``, and
Copy link
Contributor

Choose a reason for hiding this comment

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

Any migration guidance if anyone still uses these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can find discussion around the original deprecations, e.g., #84169 but I didn't find any specific migration advice.

An ast produced by ast.parse will never include instances of these classes.

The implementation of all the removed classes are pretty trivial so if you need them for some reason you can probably just copy them. e.g., AugLoad has no body beyond a docstring.

  class AugLoad(expr_context):
      """Deprecated AST node class.  Unused in Python 3."""

Copy link
Member

Choose a reason for hiding this comment

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

Yeah there's no good use for them. Most likely if people are using them, it's just some code that does something for all AST nodes, and they should simply delete the code handling these nodes. But that's guesswork.

@hugovk
Copy link
Member

hugovk commented Oct 21, 2025

Please list these in "What's new in Python 3.15" > "New deprecations" and "Pending removal in Python 3.20":

@jepler jepler requested a review from AA-Turner as a code owner October 21, 2025 15:01
@jepler
Copy link
Contributor Author

jepler commented Oct 21, 2025

Please list these in "What's new in Python 3.15" > "New deprecations" and "Pending removal in Python 3.20":

done!


(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)

* The ``__version__`` attribute has been deprecated in these standard library
Copy link
Member

Choose a reason for hiding this comment

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

This is duplicated.

"""
from _ast import *


Copy link
Member

Choose a reason for hiding this comment

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

Please revert unrelated changes.

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.

5 participants