mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#6780: merge with 3.2.
This commit is contained in:
commit
bf1253b25a
6 changed files with 53 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue