summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorKamil Turek <kamil.turek@hotmail.com>2022-11-13 23:55:58 (GMT)
committerGitHub <noreply@github.com>2022-11-13 23:55:58 (GMT)
commitbc2cdfc81571dc759a90b94dd3f4858b98cad1eb (patch)
tree9eb50f596f323b6e43a4d7dfa198c10b0abe7615 /Modules
parent14c13955c59c15bd58520241ce64e27c68028d64 (diff)
downloadcpython-bc2cdfc81571dc759a90b94dd3f4858b98cad1eb.zip
cpython-bc2cdfc81571dc759a90b94dd3f4858b98cad1eb.tar.gz
cpython-bc2cdfc81571dc759a90b94dd3f4858b98cad1eb.tar.bz2
[3.10] gh-92119: ctypes: Print exception class name instead of its representation (GH-98302) (#99452)
gh-92119: ctypes: Print exception class name instead of its representation (#98302) (cherry picked from commit b9dedfe61dce2997e3e6be318d8c50b0c19c9394)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/callproc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 4869476..e009661 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1014,7 +1014,10 @@ void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
PyErr_Fetch(&tp, &v, &tb);
PyErr_NormalizeException(&tp, &v, &tb);
- cls_str = PyObject_Str(tp);
+ if (PyType_Check(tp))
+ cls_str = PyUnicode_FromString(_PyType_Name((PyTypeObject *)tp));
+ else
+ cls_str = PyObject_Str(tp);
if (cls_str) {
PyUnicode_AppendAndDel(&s, cls_str);
PyUnicode_AppendAndDel(&s, PyUnicode_FromString(": "));