[Python-checkins] cpython (2.7): just return toplevel symbol table rather than all blocks (closes #19393)
benjamin.peterson
python-checkins at python.org
Sat Oct 26 19:22:24 CEST 2013
http://hg.python.org/cpython/rev/f1b7b5979e96
changeset: 86661:f1b7b5979e96
branch: 2.7
parent: 86652:db5a50959dc9
user: Benjamin Peterson <benjamin at python.org>
date: Sat Oct 26 13:13:51 2013 -0400
summary:
just return toplevel symbol table rather than all blocks (closes #19393)
files:
Lib/symtable.py | 5 +----
Misc/NEWS | 3 +++
Modules/symtablemodule.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Lib/symtable.py b/Lib/symtable.py
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -10,10 +10,7 @@
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
def symtable(code, filename, compile_type):
- raw = _symtable.symtable(code, filename, compile_type)
- for top in raw.itervalues():
- if top.name == 'top':
- break
+ top = _symtable.symtable(code, filename, compile_type)
return _newSymbolTable(top, filename)
class SymbolTableFactory:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@
Library
-------
+- Issue #19393: Fix symtable.symtable function to not be confused when there are
+ functions or classes named "top".
+
- Issue #19327: Fixed the working of regular expressions with too big charset.
- Issue #19350: Increasing the test coverage of macurl2path. Patch by Colin
diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c
--- a/Modules/symtablemodule.c
+++ b/Modules/symtablemodule.c
@@ -33,7 +33,7 @@
st = Py_SymtableString(str, filename, start);
if (st == NULL)
return NULL;
- t = st->st_symbols;
+ t = (PyObject *)st->st_top;
Py_INCREF(t);
PyMem_Free((void *)st->st_future);
PySymtable_Free(st);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list