Skip to content

Commit 2eada1d

Browse files
committed
Get type name only if it is a type object
1 parent 87bb82c commit 2eada1d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_ctypes/callproc.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,10 @@ void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
10191019

10201020
PyErr_Fetch(&tp, &v, &tb);
10211021
PyErr_NormalizeException(&tp, &v, &tb);
1022-
cls_str = PyType_GetName((PyTypeObject *)tp);
1022+
if (PyType_Check(tp))
1023+
cls_str = PyType_GetName((PyTypeObject *)tp);
1024+
else
1025+
cls_str = PyObject_Str(tp);
10231026
if (cls_str) {
10241027
PyUnicode_AppendAndDel(&s, cls_str);
10251028
PyUnicode_AppendAndDel(&s, PyUnicode_FromString(": "));

0 commit comments

Comments
 (0)