Commit bc1a0d42 authored by Jeroen Demeyer's avatar Jeroen Demeyer Committed by Stefan Behnel

Put __Pyx_PyMethod_New directly in the tp_descr_get slot (GH-3116)

Minor cleanup regarding __Pyx_PyMethod_New
parent 81680637
...@@ -74,7 +74,7 @@ static int __pyx_CyFunction_init(void); ...@@ -74,7 +74,7 @@ static int __pyx_CyFunction_init(void);
//////////////////// CythonFunction //////////////////// //////////////////// CythonFunction ////////////////////
//@substitute: naming //@substitute: naming
//@requires: CommonStructures.c::FetchCommonType //@requires: CommonStructures.c::FetchCommonType
////@requires: ObjectHandling.c::PyObjectGetAttrStr //@requires: ObjectHandling.c::PyMethodNew
#include <structmember.h> #include <structmember.h>
...@@ -550,11 +550,6 @@ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, ...@@ -550,11 +550,6 @@ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit,
return 0; return 0;
} }
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject* static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{ {
...@@ -701,7 +696,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { ...@@ -701,7 +696,7 @@ static PyTypeObject __pyx_CyFunctionType_type = {
__pyx_CyFunction_getsets, /*tp_getset*/ __pyx_CyFunction_getsets, /*tp_getset*/
0, /*tp_base*/ 0, /*tp_base*/
0, /*tp_dict*/ 0, /*tp_dict*/
__Pyx_CyFunction_descr_get, /*tp_descr_get*/ __Pyx_PyMethod_New, /*tp_descr_get*/
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/ offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
0, /*tp_init*/ 0, /*tp_init*/
......
...@@ -705,12 +705,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, ...@@ -705,12 +705,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
#endif #endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
// backport of PyAsyncMethods from Py3.5 to older Py3.x versions // backport of PyAsyncMethods from Py3.5 to older Py3.x versions
// (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5 // (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5
#if CYTHON_USE_ASYNC_SLOTS #if CYTHON_USE_ASYNC_SLOTS
......
...@@ -2446,3 +2446,20 @@ static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UIN ...@@ -2446,3 +2446,20 @@ static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UIN
return obj_dict_version == __Pyx_get_object_dict_version(obj); return obj_dict_version == __Pyx_get_object_dict_version(obj);
} }
#endif #endif
/////////////// PyMethodNew.proto ///////////////
#if PY_MAJOR_VERSION >= 3
// This should be an actual function (not a macro), such that we can put it
// directly in a tp_descr_get slot.
static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, CYTHON_UNUSED PyObject *typ) {
if (!self) {
Py_INCREF(func);
return func;
}
return PyMethod_New(func, self);
}
#else
#define __Pyx_PyMethod_New PyMethod_New
#endif
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