have a clear error when passing something > sys.maxsize to bytearray
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 699dec9..61fe8de 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -824,14 +824,18 @@
}
/* Is it an int? */
- count = PyNumber_AsSsize_t(arg, PyExc_ValueError);
- if (count == -1 && PyErr_Occurred())
- PyErr_Clear();
- else {
- if (count < 0) {
- PyErr_SetString(PyExc_ValueError, "negative count");
+ count = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
+ if (count == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_OverflowError))
return -1;
- }
+ else
+ PyErr_Clear();
+ }
+ else if (count < 0) {
+ PyErr_SetString(PyExc_ValueError, "negative count");
+ return -1;
+ }
+ else {
if (count > 0) {
if (PyByteArray_Resize((PyObject *)self, count))
return -1;