summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-06-16 08:10:13 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-06-16 08:10:13 (GMT)
commit83c9edc05c1d237c03fd273cb337157084a910af (patch)
tree2331ef342df6e08fea881f4d7d3b610038c2dfae
parentc60578417423bcd5263fcf19e6ff147943a72159 (diff)
downloadcpython-83c9edc05c1d237c03fd273cb337157084a910af.zip
cpython-83c9edc05c1d237c03fd273cb337157084a910af.tar.gz
cpython-83c9edc05c1d237c03fd273cb337157084a910af.tar.bz2
Fix error in comment, and in test_long_api and test_longlong_api remove
the need for the F_ERROR macro.
-rw-r--r--Modules/_testcapimodule.c8
-rw-r--r--Modules/testcapi_long.h39
2 files changed, 21 insertions, 26 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 1a95e76..1c5b0e5 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -202,7 +202,6 @@ raise_test_long_error(const char* msg)
#define F_PY_TO_S PyLong_AsLong
#define F_U_TO_PY PyLong_FromUnsignedLong
#define F_PY_TO_U PyLong_AsUnsignedLong
-#define F_ERROR raise_test_long_error
#include "testcapi_long.h"
@@ -212,7 +211,7 @@ test_long_api(PyObject* self, PyObject* args)
if (!PyArg_ParseTuple(args, ":test_long_api"))
return NULL;
- return TESTNAME();
+ return TESTNAME(raise_test_long_error);
}
#undef TESTNAME
@@ -221,7 +220,6 @@ test_long_api(PyObject* self, PyObject* args)
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_PY_TO_U
-#undef F_ERROR
#ifdef HAVE_LONG_LONG
@@ -237,7 +235,6 @@ raise_test_longlong_error(const char* msg)
#define F_PY_TO_S PyLong_AsLongLong
#define F_U_TO_PY PyLong_FromUnsignedLongLong
#define F_PY_TO_U PyLong_AsUnsignedLongLong
-#define F_ERROR raise_test_longlong_error
#include "testcapi_long.h"
@@ -247,7 +244,7 @@ test_longlong_api(PyObject* self, PyObject* args)
if (!PyArg_ParseTuple(args, ":test_longlong_api"))
return NULL;
- return TESTNAME();
+ return TESTNAME(raise_test_longlong_error);
}
#undef TESTNAME
@@ -256,7 +253,6 @@ test_longlong_api(PyObject* self, PyObject* args)
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_PY_TO_U
-#undef F_ERROR
#endif /* ifdef HAVE_LONG_LONG */
diff --git a/Modules/testcapi_long.h b/Modules/testcapi_long.h
index 7c5a7e7..8ed6b02 100644
--- a/Modules/testcapi_long.h
+++ b/Modules/testcapi_long.h
@@ -4,12 +4,11 @@
F_S_TO_PY convert signed to pylong; TYPENAME -> PyObject*
F_PY_TO_S convert pylong to signed; PyObject* -> TYPENAME
F_U_TO_PY convert unsigned to pylong; unsigned TYPENAME -> PyObject*
- F_PY_TO_U convert pylong to unsigned; PyObject* -> TypeError
- F_ERROR error-report function; char* -> PyObject* (returns NULL)
+ F_PY_TO_U convert pylong to unsigned; PyObject* -> unsigned TYPENAME
*/
static PyObject *
-TESTNAME()
+TESTNAME(PyObject *error(const char*))
{
const int NBITS = sizeof(TYPENAME) * 8;
unsigned TYPENAME base;
@@ -45,30 +44,30 @@ TESTNAME()
pyresult = F_U_TO_PY(uin);
if (pyresult == NULL)
- return F_ERROR(
+ return error(
"unsigned unexpected null result");
uout = F_PY_TO_U(pyresult);
if (uout == (unsigned TYPENAME)-1 && PyErr_Occurred())
- return F_ERROR(
+ return error(
"unsigned unexpected -1 result");
if (uout != uin)
- return F_ERROR(
+ return error(
"unsigned output != input");
UNBIND(pyresult);
in = (TYPENAME)uin;
pyresult = F_S_TO_PY(in);
if (pyresult == NULL)
- return F_ERROR(
+ return error(
"signed unexpected null result");
out = F_PY_TO_S(pyresult);
if (out == (TYPENAME)-1 && PyErr_Occurred())
- return F_ERROR(
+ return error(
"signed unexpected -1 result");
if (out != in)
- return F_ERROR(
+ return error(
"signed output != input");
UNBIND(pyresult);
}
@@ -85,18 +84,18 @@ TESTNAME()
one = PyLong_FromLong(1);
if (one == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyLong_FromLong");
/* Unsigned complains about -1? */
x = PyNumber_Negative(one);
if (x == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyNumber_Negative");
uout = F_PY_TO_U(x);
if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred())
- return F_ERROR(
+ return error(
"PyLong_AsUnsignedXXX(-1) didn't complain");
PyErr_Clear();
UNBIND(x);
@@ -104,18 +103,18 @@ TESTNAME()
/* Unsigned complains about 2**NBITS? */
y = PyLong_FromLong((long)NBITS);
if (y == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyLong_FromLong");
x = PyNumber_Lshift(one, y); /* 1L << NBITS, == 2**NBITS */
UNBIND(y);
if (x == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyNumber_Lshift");
uout = F_PY_TO_U(x);
if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred())
- return F_ERROR(
+ return error(
"PyLong_AsUnsignedXXX(2**NBITS) didn't "
"complain");
PyErr_Clear();
@@ -125,12 +124,12 @@ TESTNAME()
y = PyNumber_Rshift(x, one); /* 2**(NBITS-1) */
UNBIND(x);
if (y == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyNumber_Rshift");
out = F_PY_TO_S(y);
if (out != (TYPENAME)-1 || !PyErr_Occurred())
- return F_ERROR(
+ return error(
"PyLong_AsXXX(2**(NBITS-1)) didn't "
"complain");
PyErr_Clear();
@@ -140,18 +139,18 @@ TESTNAME()
x = PyNumber_Negative(y); /* -(2**(NBITS-1)) */
UNBIND(y);
if (x == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyNumber_Negative");
y = PyNumber_Subtract(x, one); /* -(2**(NBITS-1))-1 */
UNBIND(x);
if (y == NULL)
- return F_ERROR(
+ return error(
"unexpected NULL from PyNumber_Subtract");
out = F_PY_TO_S(y);
if (out != (TYPENAME)-1 || !PyErr_Occurred())
- return F_ERROR(
+ return error(
"PyLong_AsXXX(-2**(NBITS-1)-1) didn't "
"complain");
PyErr_Clear();