win32api registry methods and exception handling problem

Mark Hammond mhammond at skippinet.com.au
Mon Apr 28 08:50:10 EDT 2003


I've created a bug at sourceforge:

https://sourceforge.net/tracker/index.php?func=detail&aid=728896&group_id=78018&atid=551954

Thanks,

Mark.

Hung Jung Lu wrote:

> 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'





More information about the Python-list mailing list