summaryrefslogtreecommitdiffstats
path: root/Modules/testcapi_long.h
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-02-10 16:13:25 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-02-10 16:13:25 (GMT)
commit21776074cc300dbdea412aa57cb6efdd126dcff6 (patch)
tree572f170fc1e492de76de035241f3d77228c9c171 /Modules/testcapi_long.h
parenteeba356308cd6e6e11ed8c50e5d6ebac32b42e1c (diff)
downloadcpython-21776074cc300dbdea412aa57cb6efdd126dcff6.zip
cpython-21776074cc300dbdea412aa57cb6efdd126dcff6.tar.gz
cpython-21776074cc300dbdea412aa57cb6efdd126dcff6.tar.bz2
Merged revisions 69498 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69498 | mark.dickinson | 2009-02-10 15:46:50 +0000 (Tue, 10 Feb 2009) | 6 lines Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for negative arguments. Previously, it raised TypeError. Thanks Lisandro Dalcin. ........
Diffstat (limited to 'Modules/testcapi_long.h')
-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);