summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-04-16 18:43:18 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-04-16 18:43:18 (GMT)
commit5030cf1c2db98d5e83ef0c2b21e3d7a1fed50047 (patch)
treec6fa9b9f5a04bed4ad406e0a1ff0be0daa3dc10b
parent43454765c22124f4b93a131b65bbd0774aa2d51b (diff)
downloadcpython-5030cf1c2db98d5e83ef0c2b21e3d7a1fed50047.zip
cpython-5030cf1c2db98d5e83ef0c2b21e3d7a1fed50047.tar.gz
cpython-5030cf1c2db98d5e83ef0c2b21e3d7a1fed50047.tar.bz2
Fix three PyChecker-detected gotchas.
Import OPT_ symbols from _symtable. Define has_exec() and has_import_star().
-rw-r--r--Lib/symtable.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/symtable.py b/Lib/symtable.py
index 135cd56..210c339 100644
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -4,7 +4,8 @@ from __future__ import nested_scopes
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
@@ -97,7 +98,12 @@ class SymbolTable:
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()
@@ -190,10 +196,10 @@ class Symbol:
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)