Mercurial > cpython-lru_cache-weakref
diff Objects/bytesobject.c @ 69563:bcbf8c3c4a88 3.1
#6780: fix starts/endswith error message to mention that tuples are accepted too.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 26 Apr 2011 06:09:45 +0300 |
| parents | 77c657e47b5c |
| children | f4b7ecf8a5f8 f393c507717a |
line wrap: on
line diff
--- a/Objects/bytesobject.c Mon Apr 25 16:12:26 2011 -0400 +++ b/Objects/bytesobject.c Tue Apr 26 06:09:45 2011 +0300 @@ -2654,8 +2654,12 @@ 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); } @@ -2694,8 +2698,12 @@ 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); }
