Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0efee2

Browse files
committed
Fix an issue with str.translate() in IDLE -- str.translate() only accepts
a dict argument now.
1 parent f06628b commit b0efee2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/idlelib/PyParse.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,16 @@ def dump(*stuff):
9494
# Build translation table to map uninteresting chars to "x", open
9595
# brackets to "(", and close brackets to ")".
9696

97-
_tran = ['x'] * 256
97+
_tran = {}
98+
for i in range(256):
99+
_tran[i] = 'x'
98100
for ch in "({[":
99101
_tran[ord(ch)] = '('
100102
for ch in ")}]":
101103
_tran[ord(ch)] = ')'
102104
for ch in "\"'\\\n#":
103105
_tran[ord(ch)] = ch
104-
_tran = ''.join(_tran)
105-
del ch
106+
del i, ch
106107

107108
class Parser:
108109

0 commit comments

Comments
 (0)