mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bytes should be verboten in sum() (fixes #12654)
This commit is contained in:
parent
e12c0b1767
commit
ce071ca4e7
3 changed files with 10 additions and 0 deletions
|
@ -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]");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue