Skip to content

Commit 5030cf1

Browse files
committed
Fix three PyChecker-detected gotchas.
Import OPT_ symbols from _symtable. Define has_exec() and has_import_star().
1 parent 4345476 commit 5030cf1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Lib/symtable.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import _symtable
55
from _symtable import USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM, \
66
DEF_STAR, DEF_DOUBLESTAR, DEF_INTUPLE, DEF_FREE, \
7-
DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND
7+
DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND, \
8+
OPT_IMPORT_STAR, OPT_EXEC, OPT_BARE_EXEC
89

910
import weakref
1011

@@ -97,7 +98,12 @@ def has_children(self):
9798
return bool(self._table.children)
9899

99100
def has_exec(self):
100-
return bool()
101+
"""Return true if the scope uses exec"""
102+
return bool(self._table.optimized & (OPT_EXEC | OPT_BARE_EXEC))
103+
104+
def has_import_star(self):
105+
"""Return true if the scope uses import *"""
106+
return bool(self._table.optimized & OPT_IMPORT_STAR)
101107

102108
def get_identifiers(self):
103109
return self._table.symbols.keys()
@@ -190,10 +196,10 @@ def is_global(self):
190196
or (self.__flags & DEF_FREE_GLOBAL))
191197

192198
def is_vararg(self):
193-
return bool(self.flag & DEF_STAR)
199+
return bool(self.__flags & DEF_STAR)
194200

195201
def is_keywordarg(self):
196-
return bool(self.__flags & DEF_STARSTAR)
202+
return bool(self.__flags & DEF_DOUBLESTAR)
197203

198204
def is_local(self):
199205
return bool(self.__flags & DEF_BOUND)

0 commit comments

Comments
 (0)