diff options
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index d25144d617..18e6f8d8ec 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -761,14 +761,17 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds) } /* Is it an int? */ - count = PyNumber_AsSsize_t(arg, PyExc_ValueError); - if (count == -1 && PyErr_Occurred()) + count = PyNumber_AsSsize_t(arg, PyExc_OverflowError); + if (count == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; PyErr_Clear(); + } + else if (count < 0) { + PyErr_SetString(PyExc_ValueError, "negative count"); + return -1; + } else { - if (count < 0) { - PyErr_SetString(PyExc_ValueError, "negative count"); - return -1; - } if (count > 0) { if (PyByteArray_Resize((PyObject *)self, count)) return -1; |