summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/symbols.py
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-07 00:54:41 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-07 00:54:41 (GMT)
commit92c3b2190bae6dd7844c83b6acefc0b89d2bc225 (patch)
tree0cb1e4a65dab9e1ee5f24409d6c758ebc44bb3ba /Lib/compiler/symbols.py
parent98c3b85bc4b64307fc12b53210f941c6458bccb5 (diff)
downloadcpython-92c3b2190bae6dd7844c83b6acefc0b89d2bc225.zip
cpython-92c3b2190bae6dd7844c83b6acefc0b89d2bc225.tar.gz
cpython-92c3b2190bae6dd7844c83b6acefc0b89d2bc225.tar.bz2
Issue #999042: The Python compiler now handles explict global statements
correctly (should be assigned using STORE_GLOBAL opcode). This was done by having the system table differentiate between explict and implicit globals.
Diffstat (limited to 'Lib/compiler/symbols.py')
-rw-r--r--Lib/compiler/symbols.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
index 0e660ae..0bbdc71 100644
--- a/Lib/compiler/symbols.py
+++ b/Lib/compiler/symbols.py
@@ -1,7 +1,8 @@
"""Module symbol-table generator"""
from compiler import ast
-from compiler.consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL, SC_UNKNOWN
+from compiler.consts import SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICT, \
+ SC_FREE, SC_CELL, SC_UNKNOWN
from compiler.misc import mangle
import types
@@ -89,7 +90,7 @@ class Scope:
The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
"""
if name in self.globals:
- return SC_GLOBAL
+ return SC_GLOBAL_EXPLICT
if name in self.cells:
return SC_CELL
if name in self.defs:
@@ -99,7 +100,7 @@ class Scope:
if self.nested:
return SC_UNKNOWN
else:
- return SC_GLOBAL
+ return SC_GLOBAL_IMPLICIT
def get_free_vars(self):
if not self.nested:
@@ -152,7 +153,7 @@ class Scope:
if sc == SC_UNKNOWN or sc == SC_FREE \
or isinstance(self, ClassScope):
self.frees[name] = 1
- elif sc == SC_GLOBAL:
+ elif sc == SC_GLOBAL_IMPLICIT:
child_globals.append(name)
elif isinstance(self, FunctionScope) and sc == SC_LOCAL:
self.cells[name] = 1