Author mdcurran
Recipients mdcurran, theller
Date 2010-06-10.07:05:54
SpamBayes Score 0.00674455
Marked as misclassified No
Message-id <>
There seem to be problems with WINFUNCTYPE callbacks causing exceptions, and or getting their return value ignored by the caller, when using Python 2.7 rc1.
Two examples provided.

Example 1:
Providing a WINFUNCTYPE wrapped python function when calling EnumWindows from user32.dll with ctypes, EnumWindows enumerates (calls the python function) for the first 5 windows and then causes a WindowsError, sometimes an access violation (reading, or writing), or even other strange unknown exceptions.
This specific testcase is attached to the bug.
Run this script in  Python 2.7 you should see the WindowsErrors. On Python 2.6 it successfully enumerates through all windows.

Example 2:
Hooking low-level keyboard input in Windows with SetWindowsHookEx from user32.dll, providing a WINFUNCTYPE wrapped python function as the callback, and then typing some keys, causes the callback to be called but the return value is always ignored, which means the hook never blocks keys completely, even if  the value 1 is returned from the callback, to do so.
Again, a testcase is attached to the bug.
Run this script in Python. It will ask you to type some characters and press enter. On Python 2.6 no characters should be echoed to the screen, but you will hear beeps to let you know the keyboard hook is seeing the keys. On Python 2.7, the keys will be echoed to the screen, and you will also hear the beeps (meaning that the hook was seeing the keys, but was unable to actually block them -- its return value was being ignored).
Also in Python 2.7, after the quit message is sent to the hook thread, GetMessageW (in user32.dll) causes a WindowsError exception. This does not happen on Python 2.6.

Perhaps it may be related to this entry in the Python 2.7 What's new:
The underlying libffi library has been updated to version 3.0.9, containing various fixes for different platforms. (Updated by Matthias Klose; issue 8142.)
Date User Action Args
2010-06-10 07:06:00mdcurransetrecipients: + mdcurran, theller
2010-06-10 07:05:59mdcurransetmessageid: <>
2010-06-10 07:05:57mdcurranlinkissue8959 messages
2010-06-10 07:05:55mdcurrancreate