diff --git a/Objects/intobject.c b/Objects/intobject.c index 847c74d33a3..77d7e387bd8 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -27,7 +27,8 @@ static int err_ovf(char *msg) { if (PyErr_Warn(PyExc_OverflowWarning, msg) < 0) { - PyErr_SetString(PyExc_OverflowError, msg); + if (PyErr_ExceptionMatches(PyExc_OverflowWarning)) + PyErr_SetString(PyExc_OverflowError, msg); return 1; } else