Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 69562:3ceeccbc2c3b 2.7
#6780: fix starts/endswith error message to mention that tuples are accepted too.
| author | Ezio Melotti |
|---|---|
| date | Tue, 26 Apr 2011 05:12:51 +0300 |
| parents | f4da64529e8c |
| children | 60b3a5615c4e |
line wrap: on
line diff
--- a/Objects/stringobject.c Mon Apr 25 16:10:18 2011 -0400 +++ b/Objects/stringobject.c Tue Apr 26 05:12:51 2011 +0300 @@ -2918,8 +2918,12 @@ Py_RETURN_FALSE; } result = _string_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 str, " + "unicode, or tuple, not %s", Py_TYPE(subobj)->tp_name); return NULL; + } else return PyBool_FromLong(result); } @@ -2958,8 +2962,12 @@ Py_RETURN_FALSE; } result = _string_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 str, " + "unicode, or tuple, not %s", Py_TYPE(subobj)->tp_name); return NULL; + } else return PyBool_FromLong(result); }
