From 165434196c519b0721341c78383f05ea7964e454 Mon Sep 17 00:00:00 2001 From: Anisa Su Date: Mon, 3 Nov 2025 17:36:27 +0000 Subject: [PATCH] codegenerator.py: remove deprecated CDLL field _filpath In v3.12+, ctypes removed the _filepath field and now _name can be used as a path-like object. This patch removes the deprecated field which raises an AttributeError if run with Python 3.12+ Signed-off-by: Anisa Su --- ctypeslib/codegen/codegenerator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctypeslib/codegen/codegenerator.py b/ctypeslib/codegen/codegenerator.py index 7d9d9fa..03843ab 100644 --- a/ctypeslib/codegen/codegenerator.py +++ b/ctypeslib/codegen/codegenerator.py @@ -789,7 +789,7 @@ def __getattr__(self, _): if cc == "stdcall": self.need_WinLibraries() if library._name not in self._stdcall_libraries: - _ = "_stdcall_libraries[%r] =%s ctypes.WinDLL(%r)" % (library._name, stub_comment, library._filepath) + _ = "_stdcall_libraries[%r] =%s ctypes.WinDLL(%r)" % (library._name, stub_comment, library._name) print(_, file=self.imports) self._stdcall_libraries[library._name] = None return "_stdcall_libraries[%r]" % library._name @@ -801,7 +801,7 @@ def __getattr__(self, _): else: global_flag = "" if library._name not in self._c_libraries: - print("_libraries[%r] =%s ctypes.CDLL(%r%s)" % (library._name, stub_comment, library._filepath, global_flag), + print("_libraries[%r] =%s ctypes.CDLL(%r%s)" % (library._name, stub_comment, library._name, global_flag), file=self.imports) self._c_libraries[library._name] = None return "_libraries[%r]" % library._name