mirror of
https://github.com/python/cpython.git
synced 2025-07-14 23:05:17 +00:00
#6780: merge with 3.2.
This commit is contained in:
commit
bf1253b25a
6 changed files with 53 additions and 9 deletions
|
@ -9101,8 +9101,12 @@ unicode_startswith(PyUnicodeObject *self,
|
|||
Py_RETURN_FALSE;
|
||||
}
|
||||
substring = (PyUnicodeObject *)PyUnicode_FromObject(subobj);
|
||||
if (substring == NULL)
|
||||
if (substring == NULL) {
|
||||
if (PyErr_ExceptionMatches(PyExc_TypeError))
|
||||
PyErr_Format(PyExc_TypeError, "startswith first arg must be str or "
|
||||
"a tuple of str, not %s", Py_TYPE(subobj)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
result = tailmatch(self, substring, start, end, -1);
|
||||
Py_DECREF(substring);
|
||||
return PyBool_FromLong(result);
|
||||
|
@ -9145,9 +9149,12 @@ unicode_endswith(PyUnicodeObject *self,
|
|||
Py_RETURN_FALSE;
|
||||
}
|
||||
substring = (PyUnicodeObject *)PyUnicode_FromObject(subobj);
|
||||
if (substring == NULL)
|
||||
if (substring == NULL) {
|
||||
if (PyErr_ExceptionMatches(PyExc_TypeError))
|
||||
PyErr_Format(PyExc_TypeError, "endswith first arg must be str or "
|
||||
"a tuple of str, not %s", Py_TYPE(subobj)->tp_name);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
result = tailmatch(self, substring, start, end, +1);
|
||||
Py_DECREF(substring);
|
||||
return PyBool_FromLong(result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue