diff --git a/Lib/test/test_capi/test_long.py b/Lib/test/test_capi/test_long.py index 18507ed7c3bfec..05b3a7ebd63d64 100644 --- a/Lib/test/test_capi/test_long.py +++ b/Lib/test/test_capi/test_long.py @@ -208,9 +208,8 @@ def check_long_asintandoverflow(self, func, min_val, max_val): self.assertEqual(func(min_val - 1), (-1, -1)) self.assertEqual(func(max_val + 1), (-1, +1)) - - # CRASHES func(1.0) - # CRASHES func(NULL) + self.assertRaises(SystemError, func, None) + self.assertRaises(TypeError, func, 1.0) def test_long_aslong(self): # Test PyLong_AsLong() and PyLong_FromLong() diff --git a/Modules/_testcapi/long.c b/Modules/_testcapi/long.c index 9c5a0e386759e7..16eb437ffea178 100644 --- a/Modules/_testcapi/long.c +++ b/Modules/_testcapi/long.c @@ -629,7 +629,7 @@ pylong_aslongandoverflow(PyObject *module, PyObject *arg) int overflow = UNINITIALIZED_INT; long value = PyLong_AsLongAndOverflow(arg, &overflow); if (value == -1 && PyErr_Occurred()) { - assert(overflow == -1); + assert(overflow == 0); return NULL; } return Py_BuildValue("li", value, overflow); @@ -675,7 +675,7 @@ pylong_aslonglongandoverflow(PyObject *module, PyObject *arg) int overflow = UNINITIALIZED_INT; long long value = PyLong_AsLongLongAndOverflow(arg, &overflow); if (value == -1 && PyErr_Occurred()) { - assert(overflow == -1); + assert(overflow == 0); return NULL; } return Py_BuildValue("Li", value, overflow);