[Python-bugs-list] [Bug #110868] PythonWin crash on dead keys (PR#372)

noreply@sourceforge.net noreply@sourceforge.net
Thu, 10 Aug 2000 10:01:45 -0700


Bug #110868, was updated on 2000-Aug-01 14:42
Here is a current snapshot of the bug.

Project: Python
Category: Windows
Status: Open
Resolution: None
Bug Group: 3rd Party
Priority: 5
Summary: PythonWin crash on dead keys (PR#372)

Details: Jitterbug-Id: 372
Submitted-By: gottfried.ganssauge@dynix.de
Date: Tue, 27 Jun 2000 05:23:09 -0400 (EDT)
Version: 1.5.2
OS: Windows 2000


I'm using PyWin32 build 132, but the problem occurs with build 129 as well.

Every time I hit one of the dead keys on my keyboard (`, ^) PythonWin crashes.
I traced the error back to the routine ui_translate_vk() in win32uimodule.cpp.
The call to ToAsciiEx() with a dead key's scan code returns -1 and in the
following call to PyString_FromStringAndSize() this eventually leads to the
crash.
In my opininion the reason for that lies before the call to this routine.
pywin hooks WM_KEYDOWN in several places and doesn't check for dead keys but
tries to translate the scan code to an ASCII character.
With dead keys this obviously must fail.
Windows itself already does the correct translation as described in the
Platform SDK article about Dead-Character Messages:
<Quote on>
Some non-English keyboards contain character keys that are not expected to
produce characters by themselves. Instead, they are used to add a diacritic to
the character produced by the subsequent keystroke. These keys are called dead
keys. The circumflex key on a German keyboard is an example of a dead key. To
enter the character consisting of an "o" with a circumflex, a German user would
type the circumflex key followed by the "o" key. The window with the keyboard
focus would receive the following sequence of messages: 

WM_KEYDOWN 
WM_DEADCHAR 
WM_KEYUP 
WM_KEYDOWN 
WM_CHAR 
WM_KEYUP 
<Quote off>

Consequently pywin should ignore WM_KEYDOWN messages completely if they are
produced by a dead key.
I tried to implement that using the current win32api implementation, but
unfortunately the necessary API-Function to find out if a key is a dead key are
not provided in the current implementation; namely the MapVirtualKey(Ex)
function.

Cheers, and keep up the good work

Gottfried



====================================================================
Audit trail:
Tue Jul 11 08:24:21 2000	guido	moved from incoming to 3rdpartybug

Follow-Ups:

Date: 2000-Aug-01 14:42
By: none

Comment:
From: "Mark Hammond" <mhammond@skippinet.com.au>
Subject: RE: [Python-bugs-list] PythonWin crash on dead keys (PR#372)
Date: Wed, 28 Jun 2000 10:33:26 +1000

Thanks for reporting this.  Ill look into it.

In general, this bug mechanism is for Python itself, and not the Python for
Win32 extensions.  Its probably best to simply mail future bugs in the
Win32 stuff directly to me.

Mark.

> -----Original Message-----
> From: python-bugs-list-admin@python.org
> [mailto:python-bugs-list-admin@python.org]On Behalf Of
> gottfried.ganssauge@dynix.de
> Sent: Tuesday, 27 June 2000 11:08 PM
> To: python-bugs-list@python.org
> Cc: bugs-py@python.org
> Subject: [Python-bugs-list] PythonWin crash on dead keys (PR#372)
>
>
> Full_Name: Gottfried Ganßauge
> Version: 1.5.2
> OS: Windows 2000
> Submission from: joshua2go.dynix.de (195.21.130.43)
>
>
> I'm using PyWin32 build 132, but the problem occurs with build
> 129 as well.
>
> Every time I hit one of the dead keys on my keyboard (`, ^)
> PythonWin crashes.
> I traced the error back to the routine ui_translate_vk() in
> win32uimodule.cpp.
> The call to ToAsciiEx() with a dead key's scan code returns -1 and in the
> following call to PyString_FromStringAndSize() this eventually
> leads to the
> crash.
> In my opininion the reason for that lies before the call to this routine.
> pywin hooks WM_KEYDOWN in several places and doesn't check for
> dead keys but
> tries to translate the scan code to an ASCII character.
> With dead keys this obviously must fail.
> Windows itself already does the correct translation as described in the
> Platform SDK article about Dead-Character Messages:
> <Quote on>
> Some non-English keyboards contain character keys that are not
> expected to
> produce characters by themselves. Instead, they are used to add
> a diacritic to
> the character produced by the subsequent keystroke. These keys
> are called dead
> keys. The circumflex key on a German keyboard is an example of a
> dead key. To
> enter the character consisting of an "o" with a circumflex, a
> German user would
> type the circumflex key followed by the "o" key. The window with
> the keyboard
> focus would receive the following sequence of messages:
>
> WM_KEYDOWN
> WM_DEADCHAR
> WM_KEYUP
> WM_KEYDOWN
> WM_CHAR
> WM_KEYUP
> <Quote off>
>
> Consequently pywin should ignore WM_KEYDOWN messages completely
> if they are
> produced by a dead key.
> I tried to implement that using the current win32api implementation, but
> unfortunately the necessary API-Function to find out if a key is
> a dead key are
> not provided in the current implementation; namely the MapVirtualKey(Ex)
> function.
>
> Cheers, and keep up the good work
>
> Gottfried
>
>
>
> _______________________________________________
> Python-bugs-list maillist  -  Python-bugs-list@python.org
> http://www.python.org/mailman/listinfo/python-bugs-list
>



-------------------------------------------------------

Date: 2000-Aug-10 10:01
By: twouters

Comment:
Feel free to close this report if you think it shouldn't be here, Mark.

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=110868&group_id=5470