pywincffi package¶
Submodules¶
pywincffi.exceptions module¶
Exceptions¶
Custom exceptions that pywincffi
can throw.
-
exception
pywincffi.exceptions.
ConfigurationError
[source]¶ Bases:
pywincffi.exceptions.PyWinCFFIError
Raised when there was a problem with the configuration file
-
exception
pywincffi.exceptions.
InputError
(name, value, expected_types, allowed_values=None, ffi=None)[source]¶ Bases:
pywincffi.exceptions.PyWinCFFIError
A subclass of
PyWinCFFIError
that’s raised when invalid input is provided to a function. Because we’re passing inputs to C we have to be sure that the input(s) being provided are what we’re expecting so we fail early and provide better error messages.
-
exception
pywincffi.exceptions.
PyWinCFFIError
[source]¶ Bases:
exceptions.Exception
The base class for all custom exceptions that pywincffi can throw.
-
exception
pywincffi.exceptions.
PyWinCFFINotImplementedError
[source]¶ Bases:
pywincffi.exceptions.PyWinCFFIError
Raised if we encounter a situation where we can’t figure out what to do. The message for this error should contain all the information necessary to implement a future work around.
-
exception
pywincffi.exceptions.
ResourceNotFoundError
[source]¶ Bases:
pywincffi.exceptions.PyWinCFFIError
Raised when we fail to locate a specific resource
-
exception
pywincffi.exceptions.
WindowsAPIError
(function, error, errno, return_code=None, expected_return_code=None)[source]¶ Bases:
pywincffi.exceptions.PyWinCFFIError
A subclass of
PyWinCFFIError
that’s raised when there was a problem calling a Windows API function.Parameters: - function (str) – The Windows API function being called when the error was raised.
- error (str) – A string representation of the error message.
- errno (int) – An integer representing the error. This usually represents a constant which Windows has produced in response to a problem.
- return_code (int) – If the return value of a function has been checked the resulting code will be set as this value.
- expected_return_code (int) – The value we expected to receive for
code
.
pywincffi.util module¶
Utility¶
High level utilities used for converting types and working
with Python and CFFI. These are not part of pywincffi.core
because they’re not considered an internal implementation feature.
-
pywincffi.util.
string_to_cdata
(string, unicode_cast=True)[source]¶ Converts
string
to an equivalent cdata type depending on the Python version, initial type ofstring
and theunicode_cast
flag. This function is mostly meant to be used internally by pywincffi but could be used elsewhere too.Parameters: - string (str, unicode) – The string to convert to a cdata object.
- unicode_cast (bool) –
If True (the default) and running Python 2
string
will be converted to unicode prior to being processed.This defaults to True because pywincffi calls
cffi.FFI.set_unicode()
which causes types like TCHAR and LPTCSTR to point to wchar_t. In Python 3, strings are unicode by default so this extra conversion step is not necessary. In Python 2 the conversion is necessary because you end up subtle problems inside of the Windows APIs as a result
Raises: TypeError – Raised if the function can’t determine how to convert