Menu

#13 Strange exception handling in win32api registry fns

closed-fixed
win32 (141)
5
2003-07-29
2003-04-28
No

Hi,

The registry handling methods in win32api seem to have
problems with
the Python exception handling. It took me some time,
but I have
managed to isolate the problem to a simple program. But
the problem is
more severe in more complicated situations, and there
it seems to
happen with most (or all) registry methods
(win32api.Reg...()).

The methods of _winreg module do not exhibit this
problem. For now, I
am using _winreg. However, it would be nice if the
problem could be
tracked down inside the win32api's source code and be
fixed.

regards,

Hung Jung Lu

#----------------------------------------------------------------------
# OS used: Windows XP
#
# Python 2.1
# program works correctly: correct exception
message displayed
#
# Python 2.2.2 (win32all build 152)
# (a) In Pythonwin intractive window, you get
# SystemError: error return without exception set
# (b) When running with python.exe, it crashes
#
# Python 2.3b1 (win32all build 153)
# (a) In Pythonwin intractive window, you get
# SystemError: error return without exception set
# (b) When running with python.exe, program exits
silently,
# which is not the correct behavior
#
# Comments:
# (a) equivalent _winreg module methods do not have
problem.
# (b) problem seems to happen with most, or all,
win32api.Reg...()
# methods, not in this particular example, but
in more
# complicated programs (involving classes)
#

import win32con
import win32api

def reg_operation():
hkey =
win32api.RegCreateKey(win32con.HKEY_CURRENT_USER,
r'Software\Spam')
x = 3/0 # or a statement like: raise 'error'

try: reg_operation()
except: x = 5/0 # or a statement like: raise 'error'

Discussion

  • Mark Hammond

    Mark Hammond - 2003-07-29
    • status: open --> closed-fixed
     
  • Mark Hammond

    Mark Hammond - 2003-07-29

    Logged In: YES
    user_id=14198

    This has been fixed - my test_win32api module no longer
    shows a stale exception.

    Thanks!