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 type
Expected 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 in ad5e852
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