diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-03-31 15:27:00 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-03-31 15:27:00 (GMT) |
commit | ba3a16c6c3d3da0903873e9464dbc540eaeda1f7 (patch) | |
tree | 6094d419dcf56dfdb9bdb50da0a15d0c0160573a /Modules/mpzmodule.c | |
parent | 50905b557b2a46d4db432b7a9e61fe32afa557e3 (diff) | |
download | cpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.zip cpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.tar.gz cpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.tar.bz2 |
Remove METH_OLDARGS:
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Convert METH_OLDARGS -> METH_NOARGS: remove args parameter
Please review. All tests pass, but some modules don't have tests.
I spot checked various functions to try to make sure nothing broke.
Diffstat (limited to 'Modules/mpzmodule.c')
-rw-r--r-- | Modules/mpzmodule.c | 67 |
1 files changed, 7 insertions, 60 deletions
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c index e2d34b6..84685ed 100644 --- a/Modules/mpzmodule.c +++ b/Modules/mpzmodule.c @@ -1242,23 +1242,12 @@ MPZ_divm(PyObject *self, PyObject *args) } /* MPZ_divm() */ -/* MPZ methods-as-attributes */ -#ifdef MPZ_CONVERSIONS_AS_METHODS -static PyObject * -mpz_int(mpzobject *self, PyObject *args) -#else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_int(mpzobject *self) -#endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { long sli; -#ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - if (mpz_size(&self->mpz) > 1 || (sli = (long)mpz_get_ui(&self->mpz)) < (long)0 ) { PyErr_SetString(PyExc_ValueError, @@ -1273,11 +1262,7 @@ mpz_int(mpzobject *self) } /* mpz_int() */ static PyObject * -#ifdef MPZ_CONVERSIONS_AS_METHODS -mpz_long(mpzobject *self, PyObject *args) -#else /* def MPZ_CONVERSIONS_AS_METHODS */ mpz_long(mpzobject *self) -#endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { int i, isnegative; unsigned long int uli; @@ -1287,11 +1272,6 @@ mpz_long(mpzobject *self) MP_INT mpzscratch; -#ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - /* determine length of python-long to be allocated */ if ((longobjp = _PyLong_New(i = (int) ((mpz_size(&self->mpz) * BITS_PER_MP_LIMB @@ -1352,13 +1332,8 @@ mpz_long(mpzobject *self) /* I would have avoided pow() anyways, so ... */ static const double multiplier = 256.0 * 256.0 * 256.0 * 256.0; -#ifdef MPZ_CONVERSIONS_AS_METHODS -static PyObject * -mpz_float(mpzobject *self, PyObject *args) -#else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_float(mpzobject *self) -#endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { int i, isnegative; double x; @@ -1366,11 +1341,6 @@ mpz_float(mpzobject *self) MP_INT mpzscratch; -#ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - i = (int)mpz_size(&self->mpz); /* determine sign, and copy abs(self) to scratch var */ @@ -1406,40 +1376,20 @@ mpz_float(mpzobject *self) } /* mpz_float() */ -#ifdef MPZ_CONVERSIONS_AS_METHODS -static PyObject * -mpz_hex(mpzobject *self, PyObject *args) -#else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_hex(mpzobject *self) -#endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { -#ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - return mpz_format((PyObject *)self, 16, (unsigned char)1); } /* mpz_hex() */ -#ifdef MPZ_CONVERSIONS_AS_METHODS -static PyObject * -mpz_oct(mpzobject *self, PyObject *args) -#else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_oct(mpzobject *self) -#endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { -#ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - return mpz_format((PyObject *)self, 8, (unsigned char)1); } /* mpz_oct() */ static PyObject * -mpz_binary(mpzobject *self, PyObject *args) +mpz_binary(mpzobject *self) { int size; PyStringObject *strobjp; @@ -1447,9 +1397,6 @@ mpz_binary(mpzobject *self, PyObject *args) MP_INT mp; unsigned long ldigit; - if (!PyArg_NoArgs(args)) - return NULL; - if (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0) { PyErr_SetString(PyExc_ValueError, "mpz.binary() arg must be >= 0"); @@ -1493,13 +1440,13 @@ mpz_binary(mpzobject *self, PyObject *args) static PyMethodDef mpz_methods[] = { #ifdef MPZ_CONVERSIONS_AS_METHODS - {"int", mpz_int}, - {"long", mpz_long}, - {"float", mpz_float}, - {"hex", mpz_hex}, - {"oct", mpz_oct}, + {"int", mpz_int, METH_NOARGS}, + {"long", mpz_long, METH_NOARGS}, + {"float", mpz_float, METH_NOARGS}, + {"hex", mpz_hex, METH_NOARGS}, + {"oct", mpz_oct, METH_NOARGS}, #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - {"binary", (PyCFunction)mpz_binary}, + {"binary", (PyCFunction)mpz_binary, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |