summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-04-21 06:01:53 (GMT)
committerFred Drake <fdrake@acm.org>2001-04-21 06:01:53 (GMT)
commite99b97e58a274eb61d7346e786ad242e5253d3db (patch)
treec38300b8e5f878d65a960895ebdc8d86c3e7426d /Doc/tools
parentbda05564de450aa51f7416df22bc094303a95b39 (diff)
downloadcpython-e99b97e58a274eb61d7346e786ad242e5253d3db.zip
cpython-e99b97e58a274eb61d7346e786ad242e5253d3db.tar.gz
cpython-e99b97e58a274eb61d7346e786ad242e5253d3db.tar.bz2
encode(): Handle Latin-1 input characters better.
Diffstat (limited to 'Doc/tools')
-rw-r--r--Doc/tools/sgmlconv/esistools.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Doc/tools/sgmlconv/esistools.py b/Doc/tools/sgmlconv/esistools.py
index 893af76..7feeada 100644
--- a/Doc/tools/sgmlconv/esistools.py
+++ b/Doc/tools/sgmlconv/esistools.py
@@ -35,15 +35,19 @@ def decode(s):
_charmap = {}
-for c in map(chr, range(256)):
- _charmap[c] = c
+for c in range(128):
+ _charmap[chr(c)] = chr(c)
+ _charmap[unichr(c + 128)] = chr(c + 128)
_charmap["\n"] = r"\n"
_charmap["\\"] = r"\\"
del c
_null_join = ''.join
def encode(s):
- return _null_join(map(_charmap.get, s))
+ try:
+ return _null_join(map(_charmap.get, s))
+ except TypeError:
+ raise Exception("could not encode %r: %r" % (s, map(_charmap.get, s)))
class ESISReader(xml.sax.xmlreader.XMLReader):