summaryrefslogtreecommitdiffstats
path: root/Python/symtable.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-01-22 23:06:56 (GMT)
committerGitHub <noreply@github.com>2022-01-22 23:06:56 (GMT)
commit12f4ac3bc848244242d6b8a7ee158b985fd64744 (patch)
tree97646cd4908ef2ac6fd9f3b51d06a180603d3118 /Python/symtable.c
parent1ded8ed8e817b8f9dae1a0ef92d97983afbc844e (diff)
downloadcpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.zip
cpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.tar.gz
cpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.tar.bz2
bpo-46417: Clear symtable identifiers at exit (GH-30809)
Add _PySymtable_Fini() function, called by finalize_interp_clear(). Update test_cmd_line.test_showrefcount() to tolerate negative reference count.
Diffstat (limited to 'Python/symtable.c')
-rw-r--r--Python/symtable.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Python/symtable.c b/Python/symtable.c
index 01c6ec1..e9bdff3 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1121,7 +1121,7 @@ static int
symtable_add_def(struct symtable *st, PyObject *name, int flag,
int lineno, int col_offset, int end_lineno, int end_col_offset)
{
- return symtable_add_def_helper(st, name, flag, st->st_cur,
+ return symtable_add_def_helper(st, name, flag, st->st_cur,
lineno, col_offset, end_lineno, end_col_offset);
}
@@ -2134,7 +2134,7 @@ symtable_raise_if_annotation_block(struct symtable *st, const char *name, expr_t
static int
symtable_raise_if_comprehension_block(struct symtable *st, expr_ty e) {
_Py_comprehension_ty type = st->st_cur->ste_comprehension;
- PyErr_SetString(PyExc_SyntaxError,
+ PyErr_SetString(PyExc_SyntaxError,
(type == ListComprehension) ? "'yield' inside list comprehension" :
(type == SetComprehension) ? "'yield' inside set comprehension" :
(type == DictComprehension) ? "'yield' inside dict comprehension" :
@@ -2173,3 +2173,16 @@ _Py_SymtableStringObjectFlags(const char *str, PyObject *filename,
_PyArena_Free(arena);
return st;
}
+
+void
+_PySymtable_Fini(void)
+{
+ Py_CLEAR(top);
+ Py_CLEAR(lambda);
+ Py_CLEAR(genexpr);
+ Py_CLEAR(listcomp);
+ Py_CLEAR(setcomp);
+ Py_CLEAR(dictcomp);
+ Py_CLEAR(__class__);
+ Py_CLEAR(_annotation);
+}