]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41631: _ast module uses again a global state (#21961)
authorVictor Stinner <vstinner@python.org>
Tue, 15 Sep 2020 16:03:34 +0000 (18:03 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 16:03:34 +0000 (18:03 +0200)
commite5fbe0cbd4be99ced5f000ad382208ad2a561c90
treeef90c11a7bd87eee4623b061047edb1211dce422
parent7bcc6456ad4704da9b287c8045768fa53961adc5
bpo-41631: _ast module uses again a global state (#21961)

Partially revert commit ac46eb4ad6662cf6d771b20d8963658b2186c48c:
"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.
Include/internal/pycore_pylifecycle.h
Lib/ast.py
Lib/test/test_ast.py
Misc/NEWS.d/next/Core and Builtins/2020-08-26-11-23-31.bpo-41631.3jZcd9.rst [new file with mode: 0644]
Parser/asdl_c.py
Python/Python-ast.c
Python/pylifecycle.c