[Python-Dev] The -U flag
M.-A. Lemburg
mal@lemburg.com
Mon, 14 Oct 2002 09:37:06 +0200
Guido van Rossum wrote:
>>Since Python allows Unicode strings in sys.path, we are making
>>progress on getting -U to work. When entering interactive mode, the
>>stumbling block is
>>
>>_idmap = ''
>>for i in range(256): _idmap = _idmap + chr(i)
>>del i
>>
>>Here, _idmap is initialized with a Unicode string, and the chr(i)
>>results are promoted to Unicode, which eventually causes a
>>UnicodeErorr when you get past 127.
>>
>>The work-around would be to write
>>
>>_idmap = str('')
>>for i in range(256): _idmap = _idmap + chr(i)
>>del i
>>
>>With that, we can enter interactive mode in python -U.
>>
>>Is such a change acceptable?
>
>
> Only with a comment that explains it -- otherwise the next person
> looking at the code will remove it.
Wouldn't the following be faster ?
l = map(chr, range(256))
_idmap = str('').join(l)
del l
> But didn't we at one point conclude that -U was never gonna work? And
> wasn't that why it's no longer documented?
I don't remember such a conclusion. The reason for having -U
in the first place was to test the Python standard lib for
being able to handle Unicode seemlessly. Obviously we are still
far from having reached that point, but it's a good way of
being able to test the compatibility.
It's no longer documented to reduce the number of bug-reports
we get for it. It was never meant to be used by users (at this
point), just by developers.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/