mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
#6780: merge with 3.1.
This commit is contained in:
commit
f2b3f780a1
6 changed files with 53 additions and 9 deletions
|
@ -9029,8 +9029,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);
|
||||
|
@ -9073,9 +9077,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