Menu

#587 Error handling in win32gui.GetClassName

closed-fixed
nobody
win32 (141)
5
2012-04-20
2012-04-18
No

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).

Discussion

  • Roger Upole

    Roger Upole - 2012-04-20

    Fixed in changeset 4196.

     
  • Roger Upole

    Roger Upole - 2012-04-20
    • status: open --> closed-fixed
     
MongoDB Logo MongoDB