]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41796: Call _PyAST_Fini() earlier to fix a leak (GH-23131)
authorVictor Stinner <vstinner@python.org>
Tue, 3 Nov 2020 17:07:15 +0000 (18:07 +0100)
committerGitHub <noreply@github.com>
Tue, 3 Nov 2020 17:07:15 +0000 (18:07 +0100)
commitfd957c124c44441d9c5eaf61f7af8cf266bafcb1
tree2d73071bb42fe4496d11d79007eb4930fe5fd673
parent212d32f45c91849c17a82750df1ac498d63976be
bpo-41796: Call _PyAST_Fini() earlier to fix a leak (GH-23131)

Call _PyAST_Fini() on all interpreters, not only on the main
interpreter. Also, call it ealier to fix a reference leak.

Python types contain a reference to themselves in in their
PyTypeObject.tp_mro member. _PyAST_Fini() must called before the last
GC collection to destroy AST types.

_PyInterpreterState_Clear() now calls _PyAST_Fini(). It now also
calls _PyWarnings_Fini() on subinterpeters, not only on the main
interpreter.

Add an assertion in AST init_types() to ensure that the _ast module
is no longer used after _PyAST_Fini() has been called.
Include/internal/pycore_pylifecycle.h
Parser/asdl_c.py
Python/Python-ast.c
Python/pylifecycle.c
Python/pystate.c