diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-07-29 14:23:47 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-07-29 14:23:47 -0500 |
commit | ce071ca4e76b67060f55c6ed6fd9a7433cb66013 (patch) | |
tree | 92ad6b3e0b6c42c342f3ad1886902b6aa14107f6 /Python | |
parent | e12c0b1767309ec1fe727e91f8d4c0cfae4a88a8 (diff) | |
download | cpython-git-ce071ca4e76b67060f55c6ed6fd9a7433cb66013.tar.gz |
bytes should be verboten in sum() (fixes #12654)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 291ef45e67..82fb9ad165 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1888,6 +1888,11 @@ builtin_sum(PyObject *self, PyObject *args) 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]"); |