diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:40:59 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:40:59 (GMT) |
commit | f2b3f780a160347b0759b8d0f8ea9c41a456f724 (patch) | |
tree | 459bb689054d19a6cc78d46ddaa9c0ce6cc19222 /Objects/bytesobject.c | |
parent | 0fb5b398cddbf75a121b93680c8f9771f2e8499c (diff) | |
parent | ba42fd5801af664060dd90fccc4054b73967944c (diff) | |
download | cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.zip cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.tar.gz cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.tar.bz2 |
#6780: merge with 3.1.
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 9751201..38458ef 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2228,8 +2228,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); } @@ -2268,8 +2272,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); } |