diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-13 21:58:13 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-13 21:58:13 +0000 |
commit | 9c048f9f6565d9a83890d0834f5f9b4be3a7cd8b (patch) | |
tree | 64a498541cb97457d65910054a83353d35246636 /Lib/compiler/pyassem.py | |
parent | 5bad5a4be277920f10414cce238376275d40f32b (diff) | |
download | cpython-git-9c048f9f6565d9a83890d0834f5f9b4be3a7cd8b.tar.gz |
Now supports entire Python 2.0 language and still supports Python
1.5.2. The compiler generates code for the version of the interpreter
it is run under.
ast.py:
Print and Printnl add dest attr for extended print
new node AugAssign for augmented assignments
new nodes ListComp, ListCompFor, and ListCompIf for list
comprehensions
pyassem.py:
add work around for string-Unicode comparison raising UnicodeError
on comparison of two objects in code object's const table
pycodegen.py:
define VERSION, the Python major version number
get magic number using imp.get_magic() instead of hard coding
implement list comprehensions, extended print, and augmented
assignment; augmented assignment uses Delegator classes (see
doc string)
fix import and tuple unpacking for 1.5.2
transformer.py:
various changes to support new 2.0 grammar and old 1.5 grammar
add debug_tree helper than converts and symbol and token numbers
to their names
Diffstat (limited to 'Lib/compiler/pyassem.py')
-rw-r--r-- | Lib/compiler/pyassem.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py index 341127364b..dcc8bc08fa 100644 --- a/Lib/compiler/pyassem.py +++ b/Lib/compiler/pyassem.py @@ -253,8 +253,14 @@ class PyFlowGraph(FlowGraph): def _lookupName(self, name, list): """Return index of name in list, appending if necessary""" - if name in list: - i = list.index(name) + found = None + t = type(name) + for i in range(len(list)): + # must do a comparison on type first to prevent UnicodeErrors + if t == type(list[i]) and list[i] == name: + found = 1 + break + if found: # this is cheap, but incorrect in some cases, e.g 2 vs. 2L if type(name) == type(list[i]): return i |