bpo-38113: Update the Python-ast.c generator to PEP384#15957
Merged
ericsnowcurrently merged 4 commits intopython:masterfrom Sep 11, 2019
Merged
bpo-38113: Update the Python-ast.c generator to PEP384#15957ericsnowcurrently merged 4 commits intopython:masterfrom
ericsnowcurrently merged 4 commits intopython:masterfrom
Conversation
Summary: This fully migrates Python-ast.c to PEP384 and removes all statics from the whole file. This modifies the generator itself that generates the Python-ast.c
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
tiran
requested changes
Sep 11, 2019
Parser/asdl_c.py
Outdated
| "(PyObject *)%s_type);") | ||
| self.emit(line % (t.name,), 1) | ||
| self.emit("isinstance = PyObject_IsInstance(obj, " | ||
| f"astmodulestate_global->{t.name}_type);", 1) |
Member
There was a problem hiding this comment.
You cannot use f-strings here. Some platforms like old Ubuntu have python3 3.5 or older. Travis CI is failing with a SyntaxError.
|
When you're done making the requested changes, leave the comment: |
| self.emit("if (init_identifiers() < 0) return 0;", 1) | ||
| self.emit("state->AST_type = PyType_FromSpec(&AST_type_spec);", 1) | ||
| self.emit("if (!state->AST_type) return 0;", 1) | ||
| self.emit("((PyTypeObject*)state->AST_type)->tp_dictoffset = offsetof(AST_object, dict);", 1) |
Contributor
There was a problem hiding this comment.
This is still accessing the dict offset, we need to remove this by letting the type system handle it
ambv
pushed a commit
that referenced
this pull request
Sep 15, 2020
Partially revert commit ac46eb4: "bpo-38113: Update the Python-ast.c generator to PEP384 (gh-15957)". Using a module state per module instance is causing subtle practical problems. For example, the Mercurial project replaces the __import__() function to implement lazy import, whereas Python expected that "import _ast" always return a fully initialized _ast module. Add _PyAST_Fini() to clear the state at exit. The _ast module has no state (set _astmodule.m_size to 0). Remove astmodule_traverse(), astmodule_clear() and astmodule_free() functions.
pablogsal
pushed a commit
to pablogsal/cpython
that referenced
this pull request
Sep 15, 2020
Partially revert commit ac46eb4: "bpo-38113: Update the Python-ast.c generator to PEP384 (pythongh-15957)". Using a module state per module instance is causing subtle practical problems. For example, the Mercurial project replaces the __import__() function to implement lazy import, whereas Python expected that "import _ast" always return a fully initialized _ast module. Add _PyAST_Fini() to clear the state at exit. The _ast module has no state (set _astmodule.m_size to 0). Remove astmodule_traverse(), astmodule_clear() and astmodule_free() functions.. (cherry picked from commit e5fbe0c) Co-authored-by: Victor Stinner <[email protected]>
ambv
pushed a commit
that referenced
this pull request
Sep 15, 2020
…-22258) Partially revert commit ac46eb4: "bpo-38113: Update the Python-ast.c generator to PEP384 (gh-15957)". Using a module state per module instance is causing subtle practical problems. For example, the Mercurial project replaces the __import__() function to implement lazy import, whereas Python expected that "import _ast" always return a fully initialized _ast module. Add _PyAST_Fini() to clear the state at exit. The _ast module has no state (set _astmodule.m_size to 0). Remove astmodule_traverse(), astmodule_clear() and astmodule_free() functions.. (cherry picked from commit e5fbe0c) Co-authored-by: Victor Stinner <[email protected]>
xzy3
pushed a commit
to xzy3/cpython
that referenced
this pull request
Oct 18, 2020
Partially revert commit ac46eb4: "bpo-38113: Update the Python-ast.c generator to PEP384 (pythongh-15957)". Using a module state per module instance is causing subtle practical problems. For example, the Mercurial project replaces the __import__() function to implement lazy import, whereas Python expected that "import _ast" always return a fully initialized _ast module. Add _PyAST_Fini() to clear the state at exit. The _ast module has no state (set _astmodule.m_size to 0). Remove astmodule_traverse(), astmodule_clear() and astmodule_free() functions.
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.
Summary: This mostly migrates Python-ast.c to PEP384 and removes all statics from the whole file. This modifies the generator itself that generates the Python-ast.c. It leaves in the usage of _PyObject_LookupAttr even though it's not fully PEP384 compatible (this could always be shimmed in by anyone who needs it).
https://bugs.python.org/issue38113