diff options
author | Ezio Melotti <none@none> | 2011-04-26 05:12:51 +0300 |
---|---|---|
committer | Ezio Melotti <none@none> | 2011-04-26 05:12:51 +0300 |
commit | e3685f6b1b27bf089a40a12492f952dda5ff3ea2 (patch) | |
tree | c203d4df92443193797fd04fe93508711c280b92 /Objects/stringobject.c | |
parent | a0895db2e1e94a7a2dfba4f75475975720aae224 (diff) | |
download | cpython-git-e3685f6b1b27bf089a40a12492f952dda5ff3ea2.tar.gz |
#6780: fix starts/endswith error message to mention that tuples are accepted too.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 373439bca1..693f7733d9 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -2918,8 +2918,12 @@ string_startswith(PyStringObject *self, PyObject *args) 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 @@ string_endswith(PyStringObject *self, PyObject *args) 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); } |