Commits

Jeremy Hylton  committed 05436a7

Fix three PyChecker-detected gotchas.

Import OPT_ symbols from _symtable.
Define has_exec() and has_import_star().

  • Participants
  • Parent commits cbc9f88
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/symtable.py

 import _symtable
 from _symtable import USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM, \
      DEF_STAR, DEF_DOUBLESTAR, DEF_INTUPLE, DEF_FREE, \
-     DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND
+     DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND, \
+     OPT_IMPORT_STAR, OPT_EXEC, OPT_BARE_EXEC
 
 import weakref
 
         return bool(self._table.children)
 
     def has_exec(self):
-        return bool()
+        """Return true if the scope uses exec"""
+        return bool(self._table.optimized & (OPT_EXEC | OPT_BARE_EXEC))
+
+    def has_import_star(self):
+        """Return true if the scope uses import *"""
+        return bool(self._table.optimized & OPT_IMPORT_STAR)
 
     def get_identifiers(self):
         return self._table.symbols.keys()
                     or (self.__flags & DEF_FREE_GLOBAL))
 
     def is_vararg(self):
-        return bool(self.flag & DEF_STAR)
+        return bool(self.__flags & DEF_STAR)
 
     def is_keywordarg(self):
-        return bool(self.__flags & DEF_STARSTAR)
+        return bool(self.__flags & DEF_DOUBLESTAR)
 
     def is_local(self):
         return bool(self.__flags & DEF_BOUND)