diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:45:24 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:45:24 (GMT) |
commit | bf1253b25ac6fc27beb9819dade9c4465ea493fc (patch) | |
tree | 8384277a6aa3d724947bde18989d2bc4ed17e37b /Objects/unicodeobject.c | |
parent | dff18b0858a3433cc0aa457a43e63aad86900586 (diff) | |
parent | f2b3f780a160347b0759b8d0f8ea9c41a456f724 (diff) | |
download | cpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.zip cpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.tar.gz cpython-bf1253b25ac6fc27beb9819dade9c4465ea493fc.tar.bz2 |
#6780: merge with 3.2.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index efe6879..22d2137 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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); |