0
0
mirror of https://github.com/python/cpython.git synced 2024-11-28 08:20:55 +01:00

Issue #19976: Argument Clinic METH_NOARGS functions now always

take two parameters.
This commit is contained in:
Larry Hastings 2014-01-04 11:09:09 -08:00
parent 583a93943c
commit 3cceb38486
5 changed files with 150 additions and 31 deletions

View File

@ -69,4 +69,10 @@
/* Check if pointer "p" is aligned to "a"-bytes boundary. */
#define _Py_IS_ALIGNED(p, a) (!((Py_uintptr_t)(p) & (Py_uintptr_t)((a) - 1)))
#ifdef __GNUC__
#define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
#else
#define Py_UNUSED(name) _unused_ ## name
#endif
#endif /* Py_PYMACRO_H */

View File

@ -342,6 +342,11 @@ Documentation
- Issue #19795: Improved markup of True/False constants.
Tools/Demos
-----------
- Issue #19976: Argument Clinic METH_NOARGS functions now always
take two parameters.
What's New in Python 3.4.0 Beta 1?
==================================

View File

@ -3901,8 +3901,21 @@ PyDoc_STRVAR(_pickle_Pickler_clear_memo__doc__,
{"clear_memo", (PyCFunction)_pickle_Pickler_clear_memo, METH_NOARGS, _pickle_Pickler_clear_memo__doc__},
static PyObject *
_pickle_Pickler_clear_memo(PicklerObject *self)
/*[clinic checksum: 9c32be7e7a17ff82a81aae409d0d4f469033a5b2]*/
_pickle_Pickler_clear_memo_impl(PicklerObject *self);
static PyObject *
_pickle_Pickler_clear_memo(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_Pickler_clear_memo_impl((PicklerObject *)self);
return return_value;
}
static PyObject *
_pickle_Pickler_clear_memo_impl(PicklerObject *self)
/*[clinic checksum: 0574593b102fffb8e781d7bb9b536ceffc525ac1]*/
{
if (self->memo)
PyMemoTable_Clear(self->memo);
@ -4176,8 +4189,21 @@ PyDoc_STRVAR(_pickle_PicklerMemoProxy_clear__doc__,
{"clear", (PyCFunction)_pickle_PicklerMemoProxy_clear, METH_NOARGS, _pickle_PicklerMemoProxy_clear__doc__},
static PyObject *
_pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject *self)
/*[clinic checksum: 507f13938721992e175a3e58b5ad02620045a1cc]*/
_pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self);
static PyObject *
_pickle_PicklerMemoProxy_clear(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_PicklerMemoProxy_clear_impl((PicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self)
/*[clinic checksum: c6ca252530ccb3ea2f4b33507b51b183f23b24c7]*/
{
if (self->pickler->memo)
PyMemoTable_Clear(self->pickler->memo);
@ -4200,8 +4226,21 @@ PyDoc_STRVAR(_pickle_PicklerMemoProxy_copy__doc__,
{"copy", (PyCFunction)_pickle_PicklerMemoProxy_copy, METH_NOARGS, _pickle_PicklerMemoProxy_copy__doc__},
static PyObject *
_pickle_PicklerMemoProxy_copy(PicklerMemoProxyObject *self)
/*[clinic checksum: 73a5117ab354290ebdbe07bd0bf7232d0936a69d]*/
_pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self);
static PyObject *
_pickle_PicklerMemoProxy_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_PicklerMemoProxy_copy_impl((PicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self)
/*[clinic checksum: 808c4d5a37359ed5fb2efe81dbe5ff480719f470]*/
{
Py_ssize_t i;
PyMemoTable *memo;
@ -4254,11 +4293,24 @@ PyDoc_STRVAR(_pickle_PicklerMemoProxy___reduce____doc__,
{"__reduce__", (PyCFunction)_pickle_PicklerMemoProxy___reduce__, METH_NOARGS, _pickle_PicklerMemoProxy___reduce____doc__},
static PyObject *
_pickle_PicklerMemoProxy___reduce__(PicklerMemoProxyObject *self)
/*[clinic checksum: 40f0bf7a9b161e77130674f0481bda0a0184dcce]*/
_pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self);
static PyObject *
_pickle_PicklerMemoProxy___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_PicklerMemoProxy___reduce___impl((PicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self)
/*[clinic checksum: 2293152bdf53951a012d430767b608f5fb4213b5]*/
{
PyObject *reduce_value, *dict_args;
PyObject *contents = _pickle_PicklerMemoProxy_copy(self);
PyObject *contents = _pickle_PicklerMemoProxy_copy_impl(self);
if (contents == NULL)
return NULL;
@ -6288,8 +6340,21 @@ PyDoc_STRVAR(_pickle_Unpickler_load__doc__,
{"load", (PyCFunction)_pickle_Unpickler_load, METH_NOARGS, _pickle_Unpickler_load__doc__},
static PyObject *
_pickle_Unpickler_load(PyObject *self)
/*[clinic checksum: c2ae1263f0dd000f34ccf0fe59d7c544464babc4]*/
_pickle_Unpickler_load_impl(PyObject *self);
static PyObject *
_pickle_Unpickler_load(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_Unpickler_load_impl(self);
return return_value;
}
static PyObject *
_pickle_Unpickler_load_impl(PyObject *self)
/*[clinic checksum: 55f35fcaf034817e75c355ec50b7878577355899]*/
{
UnpicklerObject *unpickler = (UnpicklerObject*)self;
@ -6688,8 +6753,21 @@ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_clear__doc__,
{"clear", (PyCFunction)_pickle_UnpicklerMemoProxy_clear, METH_NOARGS, _pickle_UnpicklerMemoProxy_clear__doc__},
static PyObject *
_pickle_UnpicklerMemoProxy_clear(UnpicklerMemoProxyObject *self)
/*[clinic checksum: 46fecf4e33c0c873124f845edf6cc3a2e9864bd5]*/
_pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self);
static PyObject *
_pickle_UnpicklerMemoProxy_clear(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_UnpicklerMemoProxy_clear_impl((UnpicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self)
/*[clinic checksum: e0f99c26d48444a3f58f598bec3190c66595fce7]*/
{
_Unpickler_MemoCleanup(self->unpickler);
self->unpickler->memo = _Unpickler_NewMemo(self->unpickler->memo_size);
@ -6714,8 +6792,21 @@ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_copy__doc__,
{"copy", (PyCFunction)_pickle_UnpicklerMemoProxy_copy, METH_NOARGS, _pickle_UnpicklerMemoProxy_copy__doc__},
static PyObject *
_pickle_UnpicklerMemoProxy_copy(UnpicklerMemoProxyObject *self)
/*[clinic checksum: f8856c4e8a33540886dfbb245f286af3008fa0ad]*/
_pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self);
static PyObject *
_pickle_UnpicklerMemoProxy_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_UnpicklerMemoProxy_copy_impl((UnpicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self)
/*[clinic checksum: 8c0ab91c0b694ea71a1774650898a760d1ab4765]*/
{
Py_ssize_t i;
PyObject *new_memo = PyDict_New();
@ -6761,12 +6852,25 @@ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy___reduce____doc__,
{"__reduce__", (PyCFunction)_pickle_UnpicklerMemoProxy___reduce__, METH_NOARGS, _pickle_UnpicklerMemoProxy___reduce____doc__},
static PyObject *
_pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject *self)
/*[clinic checksum: ab5516a77659144e1191c7dd70a0c6c7455660bc]*/
_pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self);
static PyObject *
_pickle_UnpicklerMemoProxy___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = _pickle_UnpicklerMemoProxy___reduce___impl((UnpicklerMemoProxyObject *)self);
return return_value;
}
static PyObject *
_pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self)
/*[clinic checksum: 4ee76a65511291f0de2e9e63db395d2e5d6d8df6]*/
{
PyObject *reduce_value;
PyObject *constructor_args;
PyObject *contents = _pickle_UnpicklerMemoProxy_copy(self);
PyObject *contents = _pickle_UnpicklerMemoProxy_copy_impl(self);
if (contents == NULL)
return NULL;

View File

@ -1045,8 +1045,21 @@ PyDoc_STRVAR(zlib_Compress_copy__doc__,
{"copy", (PyCFunction)zlib_Compress_copy, METH_NOARGS, zlib_Compress_copy__doc__},
static PyObject *
zlib_Compress_copy(compobject *self)
/*[clinic checksum: 0b37c07f8f27deb7d4769951fbecf600a1006ef8]*/
zlib_Compress_copy_impl(compobject *self);
static PyObject *
zlib_Compress_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
return_value = zlib_Compress_copy_impl((compobject *)self);
return return_value;
}
static PyObject *
zlib_Compress_copy_impl(compobject *self)
/*[clinic checksum: 2f454ee15be3bc53cfb4e845c3f891f68be4c8e4]*/
{
compobject *retval = NULL;
int err;

View File

@ -400,19 +400,13 @@ PyDoc_STRVAR({c_basename}__doc__,
{{"{name}", (PyCFunction){c_basename}, {methoddef_flags}, {c_basename}__doc__}},
""".replace('{methoddef_flags}', flags)
def meth_noargs_pyobject_template(self, methoddef_flags=""):
return self.template_base("METH_NOARGS", methoddef_flags) + """
static PyObject *
{c_basename}({impl_parameters})
"""
def meth_noargs_template(self, methoddef_flags=""):
return self.template_base("METH_NOARGS", methoddef_flags) + """
static {impl_return_type}
{impl_prototype};
static PyObject *
{c_basename}({self_type}{self_name})
{c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored))
{{
PyObject *return_value = NULL;
{declarations}
@ -713,10 +707,7 @@ static {impl_return_type}
f.return_converter.type == 'PyObject *')
if not parameters:
if default_return_converter:
template = self.meth_noargs_pyobject_template(f.methoddef_flags)
else:
template = self.meth_noargs_template(f.methoddef_flags)
template = self.meth_noargs_template(f.methoddef_flags)
elif (len(parameters) == 1 and
parameters[0].kind == inspect.Parameter.POSITIONAL_ONLY and
not converters[0].is_optional() and