summaryrefslogtreecommitdiffstats
path: root/Tools/idle
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2000-10-06 23:09:00 (GMT)
committerTim Peters <tim.peters@gmail.com>2000-10-06 23:09:00 (GMT)
commitf2fba87dcc6bb75c126b3b1cd79e6b4b62e4981a (patch)
tree20be7fadd7fa4eb3309554a5906fe89c8ddab313 /Tools/idle
parent0a84a338f9fb578303eb4341dbf0e8514dafe7e0 (diff)
downloadcpython-f2fba87dcc6bb75c126b3b1cd79e6b4b62e4981a.zip
cpython-f2fba87dcc6bb75c126b3b1cd79e6b4b62e4981a.tar.gz
cpython-f2fba87dcc6bb75c126b3b1cd79e6b4b62e4981a.tar.bz2
Fix for next iteration of SF bug 115690 (Unicode headaches in IDLE). The
parsing functions in support of auto-indent weren't expecting Unicode strings, but text.get() can now return them (although it remains muddy as to exactly when or why that can happen). Fixed that with a Big Hammer.
Diffstat (limited to 'Tools/idle')
-rw-r--r--Tools/idle/PyParse.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Tools/idle/PyParse.py b/Tools/idle/PyParse.py
index 40b6726..ac68caa 100644
--- a/Tools/idle/PyParse.py
+++ b/Tools/idle/PyParse.py
@@ -113,6 +113,19 @@ class Parser:
def set_str(self, str):
assert len(str) == 0 or str[-1] == '\n'
+ if type(str) == type(u""):
+ # The parse functions have no idea what to do with Unicode, so
+ # replace all Unicode characters with "x". This is "safe"
+ # so long as the only characters germane to parsing the structure
+ # of Python are 7-bit ASCII. It's *necessary* because Unicode
+ # strings don't have a .translate() method that supports
+ # deletechars.
+ uniphooey = str
+ str = []
+ push = str.append
+ for raw in map(ord, uniphooey):
+ push(raw < 127 and chr(raw) or "x")
+ str = "".join(str)
self.str = str
self.study_level = 0