bpo-32892: Use ast.Constant instead of specific constant AST types.#9445
Merged
serhiy-storchaka merged 8 commits intopython:masterfrom Sep 27, 2018
Merged
bpo-32892: Use ast.Constant instead of specific constant AST types.#9445serhiy-storchaka merged 8 commits intopython:masterfrom
serhiy-storchaka merged 8 commits intopython:masterfrom
Conversation
vstinner
approved these changes
Sep 21, 2018
Member
vstinner
left a comment
There was a problem hiding this comment.
LGTM. Just a few minor comments.
| def parse_converter(self, annotation): | ||
| if (hasattr(ast, 'Constant') and | ||
| isinstance(annotation, ast.Constant) and | ||
| type(annotation.value) is str): |
Member
There was a problem hiding this comment.
"if isinstance(annotation, ast.Str):" doesn't work?
Member
Author
There was a problem hiding this comment.
I don't want to depend on deprecated classes. The initial version of my patch just removed ast.Str. It will be removed at some time in future.
| * :mod:`ast` classes ``Num``, ``Str``, ``Bytes``, ``NameConstant`` and | ||
| ``Ellipsis`` are considered deprecated and will be removed in future Python | ||
| versions. :class:`~ast.Constant` should be used instead. | ||
| (Contributed by Serhiy Storchaka in :issue:`32892`.) |
Member
There was a problem hiding this comment.
Should we mention the deprecation in ast.rst as well? Maybe near:
https://docs.python.org/dev/library/ast.html#abstract-grammar
Member
Author
There was a problem hiding this comment.
Good point! I didn't know good place for this, you have suggested me one.
tacaswell
added a commit
to tacaswell/pystemd
that referenced
this pull request
Apr 2, 2019
The `Str` object is no longer in in `_ast` is py38, switch to using the public `ast` module instead. python/cpython#9445 https://bugs.python.org/issue32892
tacaswell
added a commit
to tacaswell/pystemd
that referenced
this pull request
Apr 2, 2019
The `Str` object is no longer in in `_ast` is py38, switch to using the public `ast` module instead. python/cpython#9445 https://bugs.python.org/issue32892
tacaswell
added a commit
to tacaswell/pystemd
that referenced
this pull request
Apr 2, 2019
The `Str` object is no longer in in `_ast` is py38, switch to using the public `ast` module instead. python/cpython#9445 https://bugs.python.org/issue32892
facebook-github-bot
pushed a commit
to systemd/pystemd
that referenced
this pull request
Apr 2, 2019
Summary: The `Str` object is no longer in in `_ast` is py38, switch to using the public `ast` module instead. python/cpython#9445 https://bugs.python.org/issue32892 Pull Request resolved: #33 Differential Revision: D14721271 Pulled By: aleivag fbshipit-source-id: 1367f300f74f037983e5f6e51f7af8990f416759
hroncok
added a commit
to hroncok/mako
that referenced
this pull request
Apr 11, 2019
Since Python 3.8, class ast.Constant is used for all constants. Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and ast.Ellipsis are still available, but they will be removed in future Python releases. Constants have values, but not always ns. See sqlalchemy#287 (comment) See python/cpython#9445 Fixes Pylons/pyramid_mako#47
hroncok
added a commit
to hroncok/sphinxcontrib-bibtex
that referenced
this pull request
Apr 22, 2019
This was referenced May 3, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://bugs.python.org/issue32892