summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2021-05-21 21:02:42 (GMT)
committerGitHub <noreply@github.com>2021-05-21 21:02:42 (GMT)
commit6cc8ac949907b9a1c0f73709c6978b7a43e634e3 (patch)
tree1b7090be88bf4924021aa184bfab53d2297d3d06 /Modules
parent498383c019c1209f6fecf8f64ce44fbf437191da (diff)
downloadcpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.zip
cpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.tar.gz
cpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.tar.bz2
bpo-40736: Improve the error message for re.search() TypeError (GH-23312)
Include the invalid type in the error message.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sre.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 9d0fc4a..a313ea1 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -389,7 +389,8 @@ getstring(PyObject* string, Py_ssize_t* p_length,
/* get pointer to byte string buffer */
if (PyObject_GetBuffer(string, view, PyBUF_SIMPLE) != 0) {
- PyErr_SetString(PyExc_TypeError, "expected string or bytes-like object");
+ PyErr_Format(PyExc_TypeError, "expected string or bytes-like "
+ "object, got '%.200s'", Py_TYPE(string)->tp_name);
return NULL;
}