idle6.0 german umlauts (ascii > 128 Exception)

Alex Martelli aleaxit at yahoo.com
Tue Nov 7 14:21:37 CET 2000


"Syver Enstad" <syver.enstad at sensewave.com> wrote in message
news:8u7dp0$vif$1 at troll.powertech.no...
    [snip]
> A little experiment... Copy my Ä from this mail and paste it into idle and
> see what happens.

On my machine (NT SP6 configured as 'US'), I get a traceback, which
boils down to:

UnicodeError: ASCII encoding error: ordinal not in range(128)

if I try to do x='Ä' in IDLE.  In PythonWin, it works fine (and
print x does show uppercase-A-with-umlaut), as it does in the
command-line interactive interpreter (with a different encoding,
though; repr(x) is '\304' for Pythonwin, '\216' for the command
line -- yes, I _have_ used copy-and-paste of the identical
characted in each case).


That's on stock-Python, with
>>> sys.getdefaultencoding()
'ascii'

as set by the default site.py.


The corresponding locale.getdefaultlocale() situation:

>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')

identically in all 3 environments, of course.


Adding a sitecustomize.py to set the default encoding to
the same as the default locale's codepage, i.e. here:

import sys
sys.setdefaultencoding('cp1252')

or, also,

sys.setdefaultencoding('iso-8859-1')

makes no difference to either PythonWin or the interactive
commandline (they both keep working, as they did before --
with different codes, but correctly in themselves...),
and 'fixes' IDLE so it works like Pythonwin (code \304
for the uppercase-A-with-umlaut).

I'm not sure this procedure is "correct", but, I guess
you may want to give it a try...


Alex






More information about the Python-list mailing list