Skip to content

Commit 7735366

Browse files
committed
merge 3.3 (#19393)
2 parents a577f1e + 89d8cd9 commit 7735366

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Lib/symtable.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
1111

1212
def symtable(code, filename, compile_type):
13-
raw = _symtable.symtable(code, filename, compile_type)
14-
for top in raw.values():
15-
if top.name == 'top':
16-
break
13+
top = _symtable.symtable(code, filename, compile_type)
1714
return _newSymbolTable(top, filename)
1815

1916
class SymbolTableFactory:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Library
2626
contextlib.suppress context managers, which also ensures they provide
2727
reasonable help() output on instances
2828

29+
- Issue #19393: Fix symtable.symtable function to not be confused when there are
30+
functions or classes named "top".
31+
2932
- Issue #18685: Restore re performance to pre-PEP 393 levels.
3033

3134
- Issue #19339: telnetlib module is now using time.monotonic() when available

Modules/symtablemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ symtable_symtable(PyObject *self, PyObject *args)
3434
Py_DECREF(filename);
3535
if (st == NULL)
3636
return NULL;
37-
t = st->st_blocks;
37+
t = (PyObject *)st->st_top;
3838
Py_INCREF(t);
3939
PyMem_Free((void *)st->st_future);
4040
PySymtable_Free(st);

0 commit comments

Comments
 (0)