mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #15422: get rid of PyCFunction_New macro
This commit is contained in:
parent
914ab8420e
commit
3ba3a3ee56
9 changed files with 20 additions and 23 deletions
|
@ -115,7 +115,7 @@ classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
|||
((PyTypeObject *)type)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
return PyCFunction_New(descr->d_method, type);
|
||||
return PyCFunction_NewEx(descr->d_method, type, NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -125,7 +125,7 @@ method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
|||
|
||||
if (descr_check((PyDescrObject *)descr, obj, &res))
|
||||
return res;
|
||||
return PyCFunction_New(descr->d_method, obj);
|
||||
return PyCFunction_NewEx(descr->d_method, obj, NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -239,7 +239,7 @@ methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
func = PyCFunction_New(descr->d_method, self);
|
||||
func = PyCFunction_NewEx(descr->d_method, self, NULL);
|
||||
if (func == NULL)
|
||||
return NULL;
|
||||
args = PyTuple_GetSlice(args, 1, argc);
|
||||
|
@ -292,7 +292,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
func = PyCFunction_New(descr->d_method, self);
|
||||
func = PyCFunction_NewEx(descr->d_method, self, NULL);
|
||||
if (func == NULL)
|
||||
return NULL;
|
||||
args = PyTuple_GetSlice(args, 1, argc);
|
||||
|
|
|
@ -13,6 +13,12 @@ static int numfree = 0;
|
|||
#define PyCFunction_MAXFREELIST 256
|
||||
#endif
|
||||
|
||||
PyObject *
|
||||
PyCFunction_New(PyMethodDef *ml, PyObject *self)
|
||||
{
|
||||
return PyCFunction_NewEx(ml, self, NULL);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
|
||||
{
|
||||
|
@ -346,17 +352,3 @@ _PyCFunction_DebugMallocStats(FILE *out)
|
|||
"free PyCFunction",
|
||||
numfree, sizeof(PyCFunction));
|
||||
}
|
||||
|
||||
/* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(),
|
||||
but it's part of the API so we need to keep a function around that
|
||||
existing C extensions can call.
|
||||
*/
|
||||
|
||||
#undef PyCFunction_New
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
|
||||
|
||||
PyObject *
|
||||
PyCFunction_New(PyMethodDef *ml, PyObject *self)
|
||||
{
|
||||
return PyCFunction_NewEx(ml, self, NULL);
|
||||
}
|
||||
|
|
|
@ -3811,7 +3811,7 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
|
|||
descr = PyDescr_NewClassMethod(type, meth);
|
||||
}
|
||||
else if (meth->ml_flags & METH_STATIC) {
|
||||
PyObject *cfunc = PyCFunction_New(meth, (PyObject*)type);
|
||||
PyObject *cfunc = PyCFunction_NewEx(meth, (PyObject*)type, NULL);
|
||||
if (cfunc == NULL)
|
||||
return -1;
|
||||
descr = PyStaticMethod_New(cfunc);
|
||||
|
@ -4879,7 +4879,7 @@ add_tp_new_wrapper(PyTypeObject *type)
|
|||
|
||||
if (_PyDict_GetItemId(type->tp_dict, &PyId___new__) != NULL)
|
||||
return 0;
|
||||
func = PyCFunction_New(tp_new_methoddef, (PyObject *)type);
|
||||
func = PyCFunction_NewEx(tp_new_methoddef, (PyObject *)type, NULL);
|
||||
if (func == NULL)
|
||||
return -1;
|
||||
if (_PyDict_SetItemId(type->tp_dict, &PyId___new__, func)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue