Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Example:
>>> import ctypes>>> lib = ctypes.CDLL("some_dll")>>> lib.c_function.argtypes = [ctypes.c_char_p, ctypes.c_int]>>> lib.c_function(123, "Foobar")Traceback (most recent call last): File "<stdin>", line 1, in <module>ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong typeExpected behavior is to print exception name ("TypeError") as stated in documentation:
https://github.com/python/cpython/blob/main/Doc/library/ctypes.rst#specifying-the-required-argument-types-function-prototypes
Possible solution is to use PyType_GetName instead of PyObject_Str at
cpython/Modules/_ctypes/callproc.c
Line 1019 inad5e852
| cls_str=PyObject_Str(tp); |
but I'm not sure how to draw it up correctly.
- PR:[3.11] gh-92119: ctypes: Print exception class name instead of its representation (GH-98302) #99234