summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorTomas R <tomas.roun8@gmail.com>2023-08-03 05:29:03 (GMT)
committerGitHub <noreply@github.com>2023-08-03 05:29:03 (GMT)
commit62a3a15119cf16d216a2cc7dc10d97143017ef62 (patch)
treef8c253a053ecb8446d930fdf18b1277181054d2f /Modules
parent1cd479c6d371605e9689c88ae1789dbcbceb2da0 (diff)
downloadcpython-62a3a15119cf16d216a2cc7dc10d97143017ef62.zip
cpython-62a3a15119cf16d216a2cc7dc10d97143017ef62.tar.gz
cpython-62a3a15119cf16d216a2cc7dc10d97143017ef62.tar.bz2
gh-107455: ctypes: Improve error messages when converting to an incompatible type (#107456)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 8d4fd30..9aee37a 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1728,9 +1728,9 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
Py_DECREF(as_parameter);
return value;
}
- /* XXX better message */
- PyErr_SetString(PyExc_TypeError,
- "wrong type");
+ PyErr_Format(PyExc_TypeError,
+ "'%.200s' object cannot be interpreted "
+ "as ctypes.c_wchar_p", Py_TYPE(value)->tp_name);
return NULL;
}
@@ -1792,9 +1792,9 @@ c_char_p_from_param(PyObject *type, PyObject *value)
Py_DECREF(as_parameter);
return value;
}
- /* XXX better message */
- PyErr_SetString(PyExc_TypeError,
- "wrong type");
+ PyErr_Format(PyExc_TypeError,
+ "'%.200s' object cannot be interpreted "
+ "as ctypes.c_char_p", Py_TYPE(value)->tp_name);
return NULL;
}
@@ -1927,9 +1927,9 @@ c_void_p_from_param(PyObject *type, PyObject *value)
Py_DECREF(as_parameter);
return value;
}
- /* XXX better message */
- PyErr_SetString(PyExc_TypeError,
- "wrong type");
+ PyErr_Format(PyExc_TypeError,
+ "'%.200s' object cannot be interpreted "
+ "as ctypes.c_void_p", Py_TYPE(value)->tp_name);
return NULL;
}