diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2003-04-22 01:28:57 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2003-04-22 01:28:57 (GMT) |
commit | 699cbb767628888901d1a3c1f0ce20dd3ce1e4f9 (patch) | |
tree | 6e218838a45a42195c22c456c9884c6fd5d0c8ff /Modules/_testcapimodule.c | |
parent | dfbfe736cee70efd27cc019be2fcc2d972cdf654 (diff) | |
download | cpython-699cbb767628888901d1a3c1f0ce20dd3ce1e4f9.zip cpython-699cbb767628888901d1a3c1f0ce20dd3ce1e4f9.tar.gz cpython-699cbb767628888901d1a3c1f0ce20dd3ce1e4f9.tar.bz2 |
Get test_capi & test_getargs2 to pass on alphas
* UINT_MAX -> ULONG_MAX since we are dealing with longs
* ParseTuple needs &int for 'i' and &long for 'l'
There may be a better way to do this, but this works.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index b52e965..83f7b83 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -319,15 +319,28 @@ getargs_l(PyObject *self, PyObject *args) { PyObject *ob, *result = NULL, *argtuple; char *fmt; - long value = 0; if (!PyArg_ParseTuple(args, "sO", &fmt, &ob)) return NULL; argtuple = PyTuple_New(1); Py_INCREF(ob); PyTuple_SET_ITEM(argtuple, 0, ob); - if (PyArg_ParseTuple(argtuple, fmt, &value)) - result = PyLong_FromLong(value); + /* It's necessary to distinguish between ints and longs, since + sizeof(int) != sizeof(long) on some (64 bit) platforms. + value must be an int for: PyArg_ParseTuple(t, 'i', &value) + value must be an long for: PyArg_ParseTuple(t, 'l', &value) + */ + if (*fmt == 'i') { + int value; + if (PyArg_ParseTuple(argtuple, fmt, &value)) + result = PyLong_FromLong(value); + } else if (*fmt == 'l') { + long value; + if (PyArg_ParseTuple(argtuple, fmt, &value)) + result = PyLong_FromLong(value); + } else { + PyErr_SetString(PyExc_TypeError, "format was not i or l"); + } Py_DECREF(argtuple); return result; } @@ -384,13 +397,13 @@ test_k_code(PyObject *self) if (tuple == NULL) return NULL; - /* a number larger than UINT_MAX even on 64-bit platforms */ + /* a number larger than ULONG_MAX even on 64-bit platforms */ num = PyLong_FromString("FFFFFFFFFFFFFFFFFFFFFFFF", NULL, 16); if (num == NULL) return NULL; value = PyInt_AsUnsignedLongMask(num); - if (value != UINT_MAX) + if (value != ULONG_MAX) return raiseTestError("test_k_code", "PyInt_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); @@ -399,7 +412,7 @@ test_k_code(PyObject *self) value = -1; if (PyArg_ParseTuple(tuple, "k:test_k_code", &value) < 0) return NULL; - if (value != UINT_MAX) + if (value != ULONG_MAX) return raiseTestError("test_k_code", "k code returned wrong value for long 0xFFF...FFF"); |