It is way past time that the pywin32 exception objects grew attributes instead of only being available via indexing. In other words, instead of writing:
except win32api.error, exc: if exc[0] == ERROR_CODE: ... you can say: except win32api.error, exc: if exc.winerror == ERROR_CODE: ... Code that uses exception attributes will also port easier to py3k - but note that I'm not proposing anyone *must* use exception attributes - any changes will be backwards compatible. So - a few questions: * I've come up with the following for the names: win32api.error, exc: exc.winerror == exc[0] - 'winerror' as that is what python 2.5 and later use for the windows error code in its builtin exceptions. exc.funcname == exc[1] - 'funcname' as its close to 'filename', used by python builtin exceptions. exc.strerror == exc[2] - 'strerror' again as that is what Python builtin WindowsError exception uses, for example. pythoncom.error, exc: exc.hresult == exc[0] - not 'winerror' as its not a windows error code - it's a hresult. exc.strerror == exc[1] - strerror to be consistent. exc.excepinfo == exc[2] - named after the win32 EXCEPINFO struct. Remains a tuple without attributes. exc.argerror == exc[3] - no good reason for this name! do they sound reasonable? Speak now or forever hold your peace :) * The implementation has caused a subtle change in the way an exception is *printed* - eg, consider now: >>> win32api.CloseHandle(1) ... error: (6, 'CloseHandle', 'The handle is invalid.') versus in the new world: >>> win32api.CloseHandle(1) ... pywintypes.error: (6, 'CloseHandle', 'The handle is invalid.') Note the 'pywintypes.' prefix on the output; a com error will also be identified as coming from 'pywintypes'. The class name hasn't changed, just the way the class is instantiated has (I'm cheating by defining the classes in .py code embedded in a string in pywintypes!) Does anyone see a problem with that? Thanks, Mark _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32