Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 43577:ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
I like this because it makes the code shorter! :-)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 16 Oct 2007 18:12:55 +0000 |
| parents | 19319e70fc3e |
| children | 3e5edf19d5f0 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Tue Oct 16 06:31:30 2007 +0000 +++ b/Python/bltinmodule.c Tue Oct 16 18:12:55 2007 +0000 @@ -1595,12 +1595,19 @@ } } else { /* reject string values for 'start' parameter */ - if (PyObject_TypeCheck(result, &PyBaseString_Type)) { + if (PyUnicode_Check(result)) { PyErr_SetString(PyExc_TypeError, "sum() can't sum strings [use ''.join(seq) instead]"); Py_DECREF(iter); return NULL; } + if (PyBytes_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "sum() can't sum bytes [use b''.join(seq) instead]"); + Py_DECREF(iter); + return NULL; + } + Py_INCREF(result); } @@ -1788,7 +1795,6 @@ SETBUILTIN("NotImplemented", Py_NotImplemented); SETBUILTIN("False", Py_False); SETBUILTIN("True", Py_True); - SETBUILTIN("basestring", &PyBaseString_Type); SETBUILTIN("bool", &PyBool_Type); SETBUILTIN("memoryview", &PyMemoryView_Type); SETBUILTIN("bytes", &PyBytes_Type);
