diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:40:59 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-26 03:40:59 (GMT) |
commit | f2b3f780a160347b0759b8d0f8ea9c41a456f724 (patch) | |
tree | 459bb689054d19a6cc78d46ddaa9c0ce6cc19222 /Objects/unicodeobject.c | |
parent | 0fb5b398cddbf75a121b93680c8f9771f2e8499c (diff) | |
parent | ba42fd5801af664060dd90fccc4054b73967944c (diff) | |
download | cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.zip cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.tar.gz cpython-f2b3f780a160347b0759b8d0f8ea9c41a456f724.tar.bz2 |
#6780: merge with 3.1.
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 ddf6f2e..1f1fe8e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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); |