bpo-38113: Update the Python-ast.c generator to PEP384 by DinoV · Pull Request #15957 · python/cpython
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).
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
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| "(PyObject *)%s_type);") | ||
| self.emit(line % (t.name,), 1) | ||
| self.emit("isinstance = PyObject_IsInstance(obj, " | ||
| f"astmodulestate_global->{t.name}_type);", 1) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: I have made the requested changes; please review again.
| 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) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, 2020Partially 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, 2020Partially 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 <vstinner@python.org>
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 <vstinner@python.org>
xzy3 pushed a commit to xzy3/cpython that referenced this pull request
Oct 18, 2020Partially 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.