Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions comtypes/_comobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ def HRESULT_FROM_WIN32(errcode):
def winerror(exc):
"""Return the windows error code from a WindowsError or COMError
instance."""
try:
code = exc[0]
if isinstance(exc, COMError):
return exc.hresult
elif isinstance(exc, WindowsError):
code = exc.winerror
if isinstance(code, (int, long)):
return code
except IndexError:
pass
# Sometimes, a WindowsError instance has no error code. An access
# violation raised by ctypes has only text, for example. In this
# cases we return a generic error code.
return E_FAIL
# Sometimes, a WindowsError instance has no error code. An access
# violation raised by ctypes has only text, for example. In this
# cases we return a generic error code.
return E_FAIL
raise TypeError("Expected comtypes.COMERROR or WindowsError instance, got %s" % type(exc).__name__)


def _do_implement(interface_name, method_name):
Expand Down
2 changes: 1 addition & 1 deletion comtypes/client/_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def HandlerRoutine(dwCtrlType):
len(handles), handles,
ctypes.byref(ctypes.c_ulong()))
except WindowsError, details:
if details.args[0] != RPC_S_CALLPENDING: # timeout expired
if details.winerror != RPC_S_CALLPENDING: # timeout expired
raise
else:
raise KeyboardInterrupt
Expand Down