summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-02-10 15:46:50 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-02-10 15:46:50 (GMT)
commit4015f62e39452db0aa651edcd54b00f4e80e6bb5 (patch)
treef9d290763c2e993c0465d51a5f70387ff0598ccf /Modules
parent6a743d3694fb5138f5eab393c172c3b6789b0383 (diff)
downloadcpython-4015f62e39452db0aa651edcd54b00f4e80e6bb5.zip
cpython-4015f62e39452db0aa651edcd54b00f4e80e6bb5.tar.gz
cpython-4015f62e39452db0aa651edcd54b00f4e80e6bb5.tar.bz2
Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for
negative arguments. Previously, it raised TypeError. Thanks Lisandro Dalcin.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/testcapi_long.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/testcapi_long.h b/Modules/testcapi_long.h
index 8ed6b02..60ca326 100644
--- a/Modules/testcapi_long.h
+++ b/Modules/testcapi_long.h
@@ -97,6 +97,10 @@ TESTNAME(PyObject *error(const char*))
if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred())
return error(
"PyLong_AsUnsignedXXX(-1) didn't complain");
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+ return error(
+ "PyLong_AsUnsignedXXX(-1) raised "
+ "something other than OverflowError");
PyErr_Clear();
UNBIND(x);
@@ -112,11 +116,15 @@ TESTNAME(PyObject *error(const char*))
return error(
"unexpected NULL from PyNumber_Lshift");
- uout = F_PY_TO_U(x);
+ uout = F_PY_TO_U(x);
if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred())
return error(
"PyLong_AsUnsignedXXX(2**NBITS) didn't "
"complain");
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+ return error(
+ "PyLong_AsUnsignedXXX(2**NBITS) raised "
+ "something other than OverflowError");
PyErr_Clear();
/* Signed complains about 2**(NBITS-1)?
@@ -132,6 +140,10 @@ TESTNAME(PyObject *error(const char*))
return error(
"PyLong_AsXXX(2**(NBITS-1)) didn't "
"complain");
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+ return error(
+ "PyLong_AsXXX(2**(NBITS-1)) raised "
+ "something other than OverflowError");
PyErr_Clear();
/* Signed complains about -2**(NBITS-1)-1?;
@@ -153,6 +165,10 @@ TESTNAME(PyObject *error(const char*))
return error(
"PyLong_AsXXX(-2**(NBITS-1)-1) didn't "
"complain");
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+ return error(
+ "PyLong_AsXXX(-2**(NBITS-1)-1) raised "
+ "something other than OverflowError");
PyErr_Clear();
UNBIND(y);