]> granicus.if.org Git - python/commitdiff
Fix an issue with str.translate() in IDLE -- str.translate() only accepts
authorGuido van Rossum <guido@python.org>
Wed, 21 Nov 2007 20:07:54 +0000 (20:07 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 21 Nov 2007 20:07:54 +0000 (20:07 +0000)
a dict argument now.

Lib/idlelib/PyParse.py

index d200b6cb2dde3ab50cfe70e42be27059c559bfef..61a0003ce5ae3244bd6c4c3e6c8793fb870882db 100644 (file)
@@ -94,15 +94,16 @@ _chew_ordinaryre = re.compile(r"""
 # Build translation table to map uninteresting chars to "x", open
 # brackets to "(", and close brackets to ")".
 
-_tran = ['x'] * 256
+_tran = {}
+for i in range(256):
+    _tran[i] = 'x'
 for ch in "({[":
     _tran[ord(ch)] = '('
 for ch in ")}]":
     _tran[ord(ch)] = ')'
 for ch in "\"'\\\n#":
     _tran[ord(ch)] = ch
-_tran = ''.join(_tran)
-del ch
+del i, ch
 
 class Parser: