PyDocs

Nav

Generic Operating System Services

WinError

ctypes

functionWindows
  • WinError(code=None, descr=None)
Creates an instance of OSError. If code is not specified, GetLastError() is called to determine the error code. If descr is not specified, FormatError() is called to get a textual description of the error.
Changed in 3.3
  • 3.3: An instance of WindowsError used to be created, which is now an alias of OSError.
1 Example
>>> GetModuleHandle = windll.kernel32.GetModuleHandleA
>>> def ValidHandle(value):
...     if value == 0:
...         raise WinError()
...     return value
...
>>>
>>> GetModuleHandle.restype = ValidHandle
>>> GetModuleHandle(None)
486539264
>>> GetModuleHandle("something silly")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in ValidHandle
OSError: [Errno 126] The specified module could not be found.
>>>
from the Python docs
See Also
No see-alsos for ctypes/WinError
0 Notes
No notes for WinError