Commit 9af48ff4 authored by Guido van Rossum's avatar Guido van Rossum

Inline create_specialmethod() -- since METH_CLASS is done differently

now, it was only called once, and its existence merely obfuscates the
control flow.
parent 8d2613ad
...@@ -2494,20 +2494,6 @@ PyTypeObject PyBaseObject_Type = { ...@@ -2494,20 +2494,6 @@ PyTypeObject PyBaseObject_Type = {
/* Initialize the __dict__ in a type object */ /* Initialize the __dict__ in a type object */
static PyObject *
create_specialmethod(PyMethodDef *meth, PyObject *(*func)(PyObject *))
{
PyObject *cfunc;
PyObject *result;
cfunc = PyCFunction_New(meth, NULL);
if (cfunc == NULL)
return NULL;
result = func(cfunc);
Py_DECREF(cfunc);
return result;
}
static int static int
add_methods(PyTypeObject *type, PyMethodDef *meth) add_methods(PyTypeObject *type, PyMethodDef *meth)
{ {
...@@ -2526,7 +2512,11 @@ add_methods(PyTypeObject *type, PyMethodDef *meth) ...@@ -2526,7 +2512,11 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
descr = PyDescr_NewClassMethod(type, meth); descr = PyDescr_NewClassMethod(type, meth);
} }
else if (meth->ml_flags & METH_STATIC) { else if (meth->ml_flags & METH_STATIC) {
descr = create_specialmethod(meth, PyStaticMethod_New); PyObject *cfunc = PyCFunction_New(meth, NULL);
if (cfunc == NULL)
return -1;
descr = PyStaticMethod_New(cfunc);
Py_DECREF(cfunc);
} }
else { else {
descr = PyDescr_NewMethod(type, meth); descr = PyDescr_NewMethod(type, meth);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment