summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-09-15 18:32:56 (GMT)
committerGitHub <noreply@github.com>2020-09-15 18:32:56 (GMT)
commit55e0836849c14fb474e1ba7f37851e07660eea3c (patch)
tree95427c11bbfe568191eeb77ab20b9f779d1451e5 /Python/pylifecycle.c
parent0cc037f8a72c283bf64d1968e34cbdc22b0e3010 (diff)
downloadcpython-55e0836849c14fb474e1ba7f37851e07660eea3c.zip
cpython-55e0836849c14fb474e1ba7f37851e07660eea3c.tar.gz
cpython-55e0836849c14fb474e1ba7f37851e07660eea3c.tar.bz2
[3.9] bpo-41631: _ast module uses again a global state (GH-21961) (GH-22258)
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.. (cherry picked from commit e5fbe0cbd4be99ced5f000ad382208ad2a561c90) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 00a9b99..cfb3a7d 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1255,6 +1255,7 @@ finalize_interp_types(PyThreadState *tstate, int is_main_interp)
{
if (is_main_interp) {
/* Sundry finalizers */
+ _PyAST_Fini();
_PyFrame_Fini();
_PyTuple_Fini();
_PyList_Fini();