Mercurial > cpython-lru_cache-weakref
diff Modules/mpzmodule.c @ 22709:3aa4bf7ac31e legacy-trunk
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.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 31 Mar 2002 15:27:00 +0000 |
| parents | d38458052442 |
| children | 22fdb416ba2f |
line wrap: on
line diff
--- a/Modules/mpzmodule.c Sun Mar 31 14:57:24 2002 +0000 +++ b/Modules/mpzmodule.c Sun Mar 31 15:27:00 2002 +0000 @@ -1242,23 +1242,12 @@ } /* 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() */ 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 @@ 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 @@ /* 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 @@ 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() */ -#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 @@ 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 @@ 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 */ };
