PyShell + Umlauts

Hi,

I often experiment in long session with PyShell (for hours actually) and I have made PyShell crash several times by accidently pressing one of the umlaut-keys.

The behaviour does not occur with the python interpreter (Python.exe). Try the following:

PyShell 0.9.4 - The Flakiest Python Shell
Sponsored by Orbtech - Your source for Python programming expertise.
Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

ä

... nothing happens. PyShell hangs. Really annoying! Any workarounds?

-Andreas

This is the output from the Python interpreter (it does NOT crash):

ActivePython 2.4 Build 244 (ActiveState Corp.) based on
Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

ä

  File "<stdin>", line 1
    ?ñ
    ^
SyntaxError: invalid syntax

···

----- Original Message ----- From: "Andreas Schmid" <monkey@gmx.info>
To: "wxPython-users" <wxPython-users@lists.wxwidgets.org>
Sent: Friday, March 25, 2005 11:57 AM
Subject: [wxPython-users] PyShell + Umlauts

Hi,

I often experiment in long session with PyShell (for hours actually) and I have made PyShell crash several times by accidently pressing one of the umlaut-keys.

The behaviour does not occur with the python interpreter (Python.exe). Try the following:

PyShell 0.9.4 - The Flakiest Python Shell
Sponsored by Orbtech - Your source for Python programming expertise.
Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

ä

... nothing happens. PyShell hangs. Really annoying! Any workarounds?

-Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

And that's the python intepreter output when PyShell is launched from the command line and I enter "ä":

C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py>python PyShell.py
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\shell.py", line
372, in OnKeyDown
    self.processLine()
  File "C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\shell.py", line
591, in processLine
    self.push(command)
  File "C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\shell.py", line
673, in push
    self.more = self.interp.push(command)
  File "C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\interpreter.py"
, line 56, in push
    command = str(command) # In case the command is unicode.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordin
al not in range(128)

···

----- Original Message ----- From: "Andreas Schmid" <monkey@gmx.info>
To: "wxPython-users" <wxPython-users@lists.wxwidgets.org>
Sent: Friday, March 25, 2005 11:57 AM
Subject: [wxPython-users] PyShell + Umlauts

Hi,

I often experiment in long session with PyShell (for hours actually) and I have made PyShell crash several times by accidently pressing one of the umlaut-keys.

The behaviour does not occur with the python interpreter (Python.exe). Try the following:

PyShell 0.9.4 - The Flakiest Python Shell
Sponsored by Orbtech - Your source for Python programming expertise.
Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

ä

... nothing happens. PyShell hangs. Really annoying! Any workarounds?

-Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Patch:

Comment the following line (56) in file C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\interpreter.py:

command = str(command) # In case the command is unicode.

I just started with Python so I have no idea what the purpose of the line is. Looks to me like a forced conversion from Unicode to ASCII, which of course fails if you enter a umlaut.

Seems it's best to leave such error handling to Python :wink:

-Andreas

···

----- Original Message ----- From: "Andreas Schmid" <monkey@gmx.info>
To: "wxPython-users" <wxPython-users@lists.wxwidgets.org>
Sent: Friday, March 25, 2005 11:57 AM
Subject: [wxPython-users] PyShell + Umlauts

Hi,

I often experiment in long session with PyShell (for hours actually) and I have made PyShell crash several times by accidently pressing one of the umlaut-keys.

The behaviour does not occur with the python interpreter (Python.exe). Try the following:

PyShell 0.9.4 - The Flakiest Python Shell
Sponsored by Orbtech - Your source for Python programming expertise.
Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

ä

... nothing happens. PyShell hangs. Really annoying! Any workarounds?

-Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Andreas Schmid wrote:

Patch:

Comment the following line (56) in file C:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\py\interpreter.py:

command = str(command) # In case the command is unicode.

I just started with Python so I have no idea what the purpose of the line is. Looks to me like a forced conversion from Unicode to ASCII, which of course fails if you enter a umlaut.

Actually, it is trying to encode it using python's default encoding, which if you havn't customized your site config will be 'ascii'.

Seems it's best to leave such error handling to Python :wink:

Some things in PyShell besides this one probably expect strings, but we can certainly add some exception handling and also pick a better encoding to convert to string with.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!