Kaydet (Commit) 89d8cd94 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

just return toplevel symbol table rather than all blocks (closes #19393)

üst 050fcd51
...@@ -10,10 +10,7 @@ import weakref ...@@ -10,10 +10,7 @@ import weakref
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"] __all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
def symtable(code, filename, compile_type): def symtable(code, filename, compile_type):
raw = _symtable.symtable(code, filename, compile_type) top = _symtable.symtable(code, filename, compile_type)
for top in raw.values():
if top.name == 'top':
break
return _newSymbolTable(top, filename) return _newSymbolTable(top, filename)
class SymbolTableFactory: class SymbolTableFactory:
......
...@@ -81,6 +81,9 @@ Core and Builtins ...@@ -81,6 +81,9 @@ Core and Builtins
Library Library
------- -------
- Issue #19393: Fix symtable.symtable function to not be confused when there are
functions or classes named "top".
- Issue #19339: telnetlib module is now using time.monotonic() when available - Issue #19339: telnetlib module is now using time.monotonic() when available
to compute timeout. to compute timeout.
......
...@@ -32,7 +32,7 @@ symtable_symtable(PyObject *self, PyObject *args) ...@@ -32,7 +32,7 @@ symtable_symtable(PyObject *self, PyObject *args)
st = Py_SymtableString(str, filename, start); st = Py_SymtableString(str, filename, start);
if (st == NULL) if (st == NULL)
return NULL; return NULL;
t = st->st_blocks; t = (PyObject *)st->st_top;
Py_INCREF(t); Py_INCREF(t);
PyMem_Free((void *)st->st_future); PyMem_Free((void *)st->st_future);
PySymtable_Free(st); PySymtable_Free(st);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment