Gregor Lingl | 2 Sep 2002 00:01
Picon

Help concerning raw_input urgently needed!

Some ten days ago I posted the following to idle-dev, but
the message went into a wrong thread and was consequently
ignored. So I try it again, this time also at tutor. Several colleagues
asked me already, why this Error occurs - I still can only reply:
I don't know.
By the way: does this Error also occur when working with IDLE on
a Linux-machine? (Aren't there people with happy little Linux-Systems
in Berlin, who could check this easily?)
--------------

Some month ago I copied sitecustomize.py with
appropriate locale-setting to C:\Python22\Lib
thanks to an advice of someone on this list.

This worked well until today I made the observation,
that raw_input doesn't work correctly:

 >>> a = raw_input("Hä? ")
Hä? Tschüs
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in ?
    a = raw_input("Hä? ")
TypeError: object.readline() returned non-string
 >>>

Consequently I cannot execute programs with
raw_input from IDLE, if the expected answers (inputs)
may contain "Umlaute". Those same programs,
however, can be executed from the commandline.
And also the interactive Python interpreter can execute
(Continue reading)

Kyle Babich | 2 Sep 2002 00:51

Re: [Tutor] Help concerning raw_input urgently needed!

On Mon, 02 Sep 2002 00:01:29 +0200, "Gregor Lingl" <glingl <at> aon.at>
said:
> Some ten days ago I posted the following to idle-dev, but
> the message went into a wrong thread and was consequently
> ignored. So I try it again, this time also at tutor. Several colleagues
> asked me already, why this Error occurs - I still can only reply:
> I don't know.
> By the way: does this Error also occur when working with IDLE on
> a Linux-machine? (Aren't there people with happy little Linux-Systems
> in Berlin, who could check this easily?)
> --------------
> 
> Some month ago I copied sitecustomize.py with
> appropriate locale-setting to C:\Python22\Lib
> thanks to an advice of someone on this list.
> 
> This worked well until today I made the observation,
> that raw_input doesn't work correctly:
> 
>  >>> a = raw_input("Hä? ")
> Hä? Tschüs
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in ?
>     a = raw_input("Hä? ")
> TypeError: object.readline() returned non-string
>  >>>
> 

The program expects the raw_input to return a string, but Tschüs
according to python doesn't qualify.
(Continue reading)

Guillermo Fernandez | 2 Sep 2002 02:06
Picon
Picon
Favicon

Re: [Tutor] Help concerning raw_input urgently needed!

> Some month ago I copied sitecustomize.py with
> appropriate locale-setting to C:\Python22\Lib
> thanks to an advice of someone on this list.
> 
> This worked well until today I made the observation,
> that raw_input doesn't work correctly:
> 
>  >>> a = raw_input("Hä? ")
> Hä? Tschüs
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in ?
>     a = raw_input("Hä? ")
> TypeError: object.readline() returned non-string
>  >>>

> By the way: does this Error also occur when working with IDLE on
> a Linux-machine? (Aren't there people with happy little Linux-Systems
> in Berlin, who could check this easily?)

I'm in Australia, not in Berlin, but hope this helps :-)

I'm using linux SuSE 7.3 with Python 2.2 and this is the result:

>>> a = raw_input("Hä? ")
UnicodeError: ASCII encoding error: ordinal not in range(128)
>>> 
>>>

Regards,

(Continue reading)

Gregor Lingl | 2 Sep 2002 08:54
Picon

Re: [Tutor] Help concerning raw_input urgently needed!

Kyle Babich schrieb:

>On Mon, 02 Sep 2002 00:01:29 +0200, "Gregor Lingl" <glingl <at> aon.at>
>said:
>  
>
>>...
>>Some month ago I copied sitecustomize.py with
>>appropriate locale-setting to C:\Python22\Lib
>>thanks to an advice of someone on this list.
>>
>>This worked well until today I made the observation,
>>that raw_input doesn't work correctly:
>>
>> >>> a = raw_input("Hä? ")
>>Hä? Tschüs
>>Traceback (most recent call last):
>>  File "<pyshell#2>", line 1, in ?
>>    a = raw_input("Hä? ")
>>TypeError: object.readline() returned non-string
>> >>>
>>
>>    
>>
>
>The program expects the raw_input to return a string, but Tschüs
>according to python doesn't qualify.
>
>  
>
(Continue reading)

Magnus Lycka | 2 Sep 2002 11:08
Picon

Re: [Tutor] Help concerning raw_input urgently needed!

At 08:54 2002-09-02 +0200, Gregor Lingl wrote:
>Moreover this occurs only within IDLE, not when using the 
>python-interactive-interpreter.

I think the problem is that Tcl/Tk use Unicode these days,
and Python defaults to ISO8859-1. Thus your umlaut is ok
for raw_input in python proper. In IDLE, the characters are
recieved by Tk, and translated from Unicode. That fails on
any non-ASCII value, since these are ambiguous unless a
code page is supplied.

I've stumbled over similar Unicode/ASCII problems before with
IDLE. There has also been bugs previously that made it impossible
to enter floats such as "pi = 3.14" if the national settings
in Windows assumed decimal comma, such as in Swedish settings
etc. I didn't get a lot of response reagarding those problems.
(That was before IDLE was a "project".)

Maybe there were good and simple solutions for these things,
but I sure didn't manage to find them, and I didn't manage to
get any attention. It's seems the idle-dev mailing list is
equally uninterested now.

In general I find it difficult to find good information about
internationalization and localization issues for Python. Neither
in books, on the net, nor in mailing lists. Maybe it would work
better if I was fluent in German or Japanese... ;) After all
most of those who write in English don't need to worry about it...

My advice would be to avoid IDLE. I prefer PythonWin in Windows,
(Continue reading)

Guido van Rossum | 2 Sep 2002 16:09
Favicon

Re: Re: [Tutor] Help concerning raw_input urgently needed!

> I think the problem is that Tcl/Tk use Unicode these days,
> and Python defaults to ISO8859-1.

That's not true.

> Thus your umlaut is ok for raw_input in python proper. In IDLE, the
> characters are recieved by Tk, and translated from Unicode. That
> fails on any non-ASCII value, since these are ambiguous unless a
> code page is supplied.

Try the IDLE from current CVS.  AFAIK the Unicode issues have been
fixed there.

--Guido van Rossum (home page: http://www.python.org/~guido/)
Patrick K. O'Brien | 2 Sep 2002 16:26

RE: Re: [Tutor] Help concerning raw_input urgently needed!

[Magnus Lycka]
>
> PyCrust is a beginning.

Thanks for the plug and the opportunity to jump in here and mention that
PyCrust has several non-English users who have helped me make PyCrust
international language friendly. The PyCrust that is currently in CVS, and
that will ship with the next release of wxPython (version 2.3.3), does
support your original example:

Welcome To PyCrust 0.7.2 - The Flakiest Python Shell
Sponsored by Orbtech - Your source for Python programming expertise.
Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
Startup script executed: C:\Code\.pythonrc.py
>>> a = raw_input("Hä? ")
Hä? Tschüs
>>> a
'Tsch\xfcs'
>>> print a
Tschüs
>>>

Also, I did *not* need to create a sitecustomize.py file for this to work.
That said, IDLE is still getting worked on and hopefully this issue will be
addressed.

--
Patrick K. O'Brien
Orbtech
(Continue reading)

Patrick K. O'Brien | 2 Sep 2002 16:30

RE: Re: [Tutor] Help concerning raw_input urgently needed!

[Guido van Rossum]
>
> Try the IDLE from current CVS.  AFAIK the Unicode issues have been
> fixed there.

I just updated from CVS and gave it a try. :-(

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
GRPC IDLE Fork 0.8.2
>>> a = raw_input("Hä? ")
UnicodeError: ASCII encoding error: ordinal not in range(128)

--
Patrick K. O'Brien
Orbtech
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
Web:  http://www.orbtech.com/web/pobrien/
Blog: http://www.orbtech.com/blog/pobrien/
Wiki: http://www.orbtech.com/wiki/PatrickOBrien
-----------------------------------------------
Gregor Lingl | 2 Sep 2002 19:19
Picon

Re: Re: [Tutor] Help concerning raw_input urgently needed!

Guido van Rossum schrieb:

>>I think the problem is that Tcl/Tk use Unicode these days,
>>and Python defaults to ISO8859-1.
>>    
>>
>
>That's not true.
>
>  
>
>>Thus your umlaut is ok for raw_input in python proper. In IDLE, the
>>characters are recieved by Tk, and translated from Unicode. That
>>fails on any non-ASCII value, since these are ambiguous unless a
>>code page is supplied.
>>    
>>
>
>Try the IDLE from current CVS.  AFAIK the Unicode issues have been
>fixed there.
>
>--Guido van Rossum (home page: http://www.python.org/~guido/)
>  
>
No, the problem addressed has not been fixed there.
I don't know, if Unicode issues are involved, but anyway we find:

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE Fork 0.8 -- press F1 for help
(Continue reading)

Guido van Rossum | 2 Sep 2002 21:02
Favicon

Re: Re: [Tutor] Help concerning raw_input urgently needed!

> [Guido van Rossum]
> >
> > Try the IDLE from current CVS.  AFAIK the Unicode issues have been
> > fixed there.
> 
> I just updated from CVS and gave it a try. :-(
> 
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> GRPC IDLE Fork 0.8.2
> >>> a = raw_input("Hä? ")
> UnicodeError: ASCII encoding error: ordinal not in range(128)

Sorry, that's the idlefork IDLE.  I meant the core Python CVS.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Gmane