summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/symbols.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-15 08:58:59 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-15 08:58:59 (GMT)
commit2d2fe572a4605d3c25055717c1033589e2889e65 (patch)
treec5d67af0ba51c48f36bf7117539f26ea04b496fe /Lib/compiler/symbols.py
parentcbc1ed5e2811d2ef7dbf243a1adbcf1c9bf6cba1 (diff)
downloadcpython-2d2fe572a4605d3c25055717c1033589e2889e65.zip
cpython-2d2fe572a4605d3c25055717c1033589e2889e65.tar.gz
cpython-2d2fe572a4605d3c25055717c1033589e2889e65.tar.bz2
#4578: fix has_key() usage in compiler package.
Diffstat (limited to 'Lib/compiler/symbols.py')
-rw-r--r--Lib/compiler/symbols.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
index 8f62980..0e660ae 100644
--- a/Lib/compiler/symbols.py
+++ b/Lib/compiler/symbols.py
@@ -49,9 +49,9 @@ class Scope:
def add_global(self, name):
name = self.mangle(name)
- if self.uses.has_key(name) or self.defs.has_key(name):
+ if name in self.uses or name in self.defs:
pass # XXX warn about global following def/use
- if self.params.has_key(name):
+ if name in self.params:
raise SyntaxError, "%s in %s is global and parameter" % \
(name, self.name)
self.globals[name] = 1
@@ -88,14 +88,13 @@ class Scope:
The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
"""
- if self.globals.has_key(name):
+ if name in self.globals:
return SC_GLOBAL
- if self.cells.has_key(name):
+ if name in self.cells:
return SC_CELL
- if self.defs.has_key(name):
+ if name in self.defs:
return SC_LOCAL
- if self.nested and (self.frees.has_key(name) or
- self.uses.has_key(name)):
+ if self.nested and (name in self.frees or name in self.uses):
return SC_FREE
if self.nested:
return SC_UNKNOWN
@@ -108,8 +107,7 @@ class Scope:
free = {}
free.update(self.frees)
for name in self.uses.keys():
- if not (self.defs.has_key(name) or
- self.globals.has_key(name)):
+ if name not in self.defs and name not in self.globals:
free[name] = 1
return free.keys()
@@ -134,7 +132,7 @@ class Scope:
free.
"""
self.globals[name] = 1
- if self.frees.has_key(name):
+ if name in self.frees:
del self.frees[name]
for child in self.children:
if child.check_name(name) == SC_FREE: