[Python-checkins] r73627 - in python/trunk/Lib: symtable.py test/test_symtable.py
benjamin.peterson
python-checkins at python.org
Sun Jun 28 21:27:55 CEST 2009
Author: benjamin.peterson
Date: Sun Jun 28 21:27:55 2009
New Revision: 73627
Log:
return locals and cells in get_locals() not bound globals, though
Modified:
python/trunk/Lib/symtable.py
python/trunk/Lib/test/test_symtable.py
Modified: python/trunk/Lib/symtable.py
==============================================================================
--- python/trunk/Lib/symtable.py (original)
+++ python/trunk/Lib/symtable.py Sun Jun 28 21:27:55 2009
@@ -3,7 +3,7 @@
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM,
DEF_IMPORT, DEF_BOUND, OPT_IMPORT_STAR, OPT_EXEC, OPT_BARE_EXEC,
- SCOPE_OFF, SCOPE_MASK, FREE, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT)
+ SCOPE_OFF, SCOPE_MASK, FREE, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL, LOCAL)
import weakref
@@ -137,7 +137,9 @@
def get_locals(self):
if self.__locals is None:
- self.__locals = self.__idents_matching(lambda x:x & DEF_BOUND)
+ locs = (LOCAL, CELL)
+ test = lambda x: ((x >> SCOPE_OFF) & SCOPE_MASK) in locs
+ self.__locals = self.__idents_matching(test)
return self.__locals
def get_globals(self):
Modified: python/trunk/Lib/test/test_symtable.py
==============================================================================
--- python/trunk/Lib/test/test_symtable.py (original)
+++ python/trunk/Lib/test/test_symtable.py Sun Jun 28 21:27:55 2009
@@ -92,7 +92,7 @@
func = self.spam
self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var"))
self.assertEqual(func.get_locals(),
- ("a", "b", "bar", "internal", "kw", "var", "x"))
+ ("a", "b", "internal", "kw", "var", "x"))
self.assertEqual(func.get_globals(), ("bar", "glob"))
self.assertEqual(self.internal.get_frees(), ("x",))
More information about the Python-checkins
mailing list