Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 71610:7368d0e9b33e
bytes should be verboten in sum() (fixes #12654)
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 29 Jul 2011 14:23:47 -0500 |
| parents | 13e6d3cb2ecd |
| children | a6afd26caa8a |
line wrap: on
line diff
--- a/Python/bltinmodule.c Fri Jul 29 19:00:38 2011 +0200 +++ b/Python/bltinmodule.c Fri Jul 29 14:23:47 2011 -0500 @@ -1888,6 +1888,11 @@ Py_DECREF(iter); return NULL; } + if (PyBytes_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "sum() can't sum bytes [use b''.join(seq) instead]"); + return NULL; + } if (PyByteArray_Check(result)) { PyErr_SetString(PyExc_TypeError, "sum() can't sum bytes [use b''.join(seq) instead]");
