Error handling in win32gui.GetClassName
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
When the handle passed to win32gui.GetClassName is invalid (perhaps because the window was previously destroyed), it calls PyWin_SetAPIError, but then returns the empty string (instead of NULL). This causes the exception to be raised some time later depending on the following code.
At an interactive interpreter, I get:
>>> win32gui.GetClassName(0)
''
>>>
pywintypes.error: (1400, 'GetClassName', 'Invalid window handle.')
>>>
At the second prompt, I just press enter.
If pyreadline is installed, a full traceback from somewhere in pyreadline is printed immediately after the first line.
I suspect the problem is in win32/src/win32gui.i on line 5999 (as of 6e918dcbc8c7), which should return PyWin_SetAPIError (or explicitly return NULL).
Fixed in changeset 4196.