Skip to content

ctypes.CDLL._filepath deprecated #148

@anisa-su993

Description

@anisa-su993

ctypes documentation notes that "Changed in version 3.12: The name parameter can now be a path-like object." Upon checking source code, the CDLL class no longer has a _filepath attribute.

This causes the following error in codegenerator.py:

 File "/root/libcxlmi/venv/lib/python3.13/site-packages/ctypeslib/codegen/codegenerator.py", line 804, in get_sharedlib
    print("_libraries[%r] =%s ctypes.CDLL(%r%s)" % (library._name, stub_comment, library._filepath, global_flag),
                                                                                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/ctypes/__init__.py", line 403, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.13/ctypes/__init__.py", line 408, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/lib/x86_64-linux-gnu/libcxlmi.so: undefined symbol: _filepath

The fix is just to change _filepath to _name in line 804 and 702, but not sure if we want to force users to use Python 3.12+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions