DLLs and determine which one is not found using Windows debugging and
tracing tools.
+ .. versionchanged:: 3.12
+
+ The *name* parameter can now be a :term:`path-like object`.
+
.. seealso::
`Microsoft DUMPBIN tool <https://docs.microsoft.com/cpp/build/reference/dependents>`_
.. versionchanged:: 3.3
:exc:`WindowsError` used to be raised.
+ .. versionchanged:: 3.12
+
+ The *name* parameter can now be a :term:`path-like object`.
+
.. class:: WinDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None)
functions in these libraries use the ``stdcall`` calling convention, and are
assumed to return :c:expr:`int` by default.
+ .. versionchanged:: 3.12
+
+ The *name* parameter can now be a :term:`path-like object`.
+
The Python :term:`global interpreter lock` is released before calling any
function exported by these libraries, and reacquired afterwards.
Thus, this is only useful to call Python C api functions directly.
+ .. versionchanged:: 3.12
+
+ The *name* parameter can now be a :term:`path-like object`.
+
All these classes can be instantiated by calling them with at least one
argument, the pathname of the shared library. If you have an existing handle to
an already loaded shared library, it can be passed as the ``handle`` named
unknowndll = "xxrandomnamexx"
def test_load(self):
- if libc_name is None:
- self.skipTest('could not find libc')
- CDLL(libc_name)
- CDLL(os.path.basename(libc_name))
+ if libc_name is not None:
+ test_lib = libc_name
+ else:
+ if os.name == "nt":
+ import _ctypes_test
+ test_lib = _ctypes_test.__file__
+ else:
+ self.skipTest('could not find library to load')
+ CDLL(test_lib)
+ CDLL(os.path.basename(test_lib))
+ class CTypesTestPathLikeCls:
+ def __fspath__(self):
+ return test_lib
+ CDLL(CTypesTestPathLikeCls())
self.assertRaises(OSError, CDLL, self.unknowndll)
def test_load_version(self):