diff options
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 7561ae5..ea14be6 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2224,8 +2224,12 @@ bytes_startswith(PyBytesObject *self, PyObject *args) Py_RETURN_FALSE; } result = _bytes_tailmatch(self, subobj, start, end, -1); - if (result == -1) + if (result == -1) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, "startswith first arg must be bytes " + "or a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); return NULL; + } else return PyBool_FromLong(result); } @@ -2264,8 +2268,12 @@ bytes_endswith(PyBytesObject *self, PyObject *args) Py_RETURN_FALSE; } result = _bytes_tailmatch(self, subobj, start, end, +1); - if (result == -1) + if (result == -1) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or " + "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); return NULL; + } else return PyBool_FromLong(result); } |