[pywin32-bugs] [ pywin32-Bugs-3003706 ] pywintypes.error should inherit from WindowsError
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2010-05-18 22:48:55
|
Bugs item #3003706, was opened at 2010-05-18 22:48 Message generated for change (Tracker Item Submitted) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3003706&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: win32 Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: gz () Assigned to: Nobody/Anonymous (nobody) Summary: pywintypes.error should inherit from WindowsError Initial Comment: Exceptions thrown by system calls in Python functions throw an EnvironmentError subclass, ctypes.WinError creates a WindowsError, extension modules using windows system calls throw some kind of OSError, but pywin32 has its own exception type that can't be caught at the same time as any of these. This means we've got an odd case in our code, where there are two nearly identical implementations of a class, one using ctypes and one using pywin32, but the generic error handling code treated them differently because pywintypes.error isn't an EnvironmentError, see <https://bugs.launchpad.net/bzr/+bug/572201>. The current code in win32/src/PyWinTypesmodule.cpp is like: class error(Exception): def __init__(self, *args, **kw): self.winerror, self.funcname, self.strerror = args[:3] Exception.__init__(self, *args, **kw) It could be changed to something along the lines of: class error(WindowsException): def __init__(self, winerror, strerror, funcname, filename=None): WindowsException.__init__(self, winerror, strerror, filename) self.funcname = funcname This would also mean it got pretty stringifying rather than the ugly 3-tuple repr it has currently. Changing the base type probably would break some code with carefully ordered except blocks, but would be a good thing in the long run. The pywintypes.com_error should probably remain descended from plain Exception, comtypes.COMError is as well. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3003706&group_id=78018 |