summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-04-26 03:45:24 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2011-04-26 03:45:24 (GMT)
commitbf1253b25ac6fc27beb9819dade9c4465ea493fc (patch)
tree8384277a6aa3d724947bde18989d2bc4ed17e37b /Objects/bytesobject.c
parentdff18b0858a3433cc0aa457a43e63aad86900586 (diff)
parentf2b3f780a160347b0759b8d0f8ea9c41a456f724 (diff)
downloadcpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.zip
cpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.tar.gz
cpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.tar.bz2
#6780: merge with 3.2.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c12
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);
}