[Python-Dev] Re: [Python-checkins] python/dist/src/Lib textwrap.py,1.18,1.19
Greg Ward
gward@python.net
Wed, 11 Dec 2002 08:49:58 -0500
On 11 December 2002, Just van Rossum said:
> This checkin makes textwrap fail for me when running python -S ("don't run
> site.py"):
>
> Python 2.3a0 (#42, Dec 11 2002, 10:33:42)
> [GCC 3.1 20020420 (prerelease)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import textwrap
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/Users/just/code/python_cvs/Lib/textwrap.py", line 15, in ?
> class TextWrapper:
> File "/Users/just/code/python_cvs/Lib/textwrap.py", line 56, in TextWrapper
> unicode_whitespace_trans[ord(unicode(c))] = ord(u' ')
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 0: ordinal
> not in range(128)
> >>>
Weird. What the heck is 0xa0 doing in string.whitespace? Oh, waitasec,
0xa0 is non-breaking-space in ISO-8859-1. But no, string.whitespace is
hardcoded to the US-ASCII whitespace chars, all of which are in
range(128) -- your locale shouldn't matter.
Just, can you run the following commands and tell me what you get:
python -c "import string; print [hex(ord(c)) for c in string.whitespace]"
python -S -c "import string; print [hex(ord(c)) for c in string.whitespace]"
LANG=C python -c "import string; print [hex(ord(c)) for c in string.whitespace]"
LANG=C python -S -c "import string; print [hex(ord(c)) for c in string.whitespace]"
(On my Linux box where LANG=en_CA normally, I always get the six
US-ASCII whitespace chars.)
Greg
--
Greg Ward <gward@python.net> http://www.gerg.ca/
This quote intentionally left blank.