diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-10-08 21:00:26 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-10-08 21:00:26 +0200 |
commit | 55d87d498ef281f1a5e66c3d2c07f2e09f0cbcef (patch) | |
tree | 9f6f25a8f14b7a491f3313a01facef683bf55711 | |
parent | 6b21b89a4f08065cad97ed2a2d605c63ce3e866d (diff) | |
download | cython-55d87d498ef281f1a5e66c3d2c07f2e09f0cbcef.tar.gz |
fix PyMethod_New() in pypy3
-rw-r--r-- | Cython/Compiler/ExprNodes.py | 4 | ||||
-rw-r--r-- | Cython/Utility/CythonFunction.c | 5 | ||||
-rw-r--r-- | Cython/Utility/ModuleSetupCode.c | 8 |
3 files changed, 11 insertions, 6 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index e22b9faa9..29fa1d094 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -7518,7 +7518,7 @@ class BoundMethodNode(ExprNode): def generate_result_code(self, code): code.putln( - "%s = PyMethod_New(%s, %s, (PyObject*)%s->ob_type); %s" % ( + "%s = __Pyx_PyMethod_New(%s, %s, (PyObject*)%s->ob_type); %s" % ( self.result(), self.function.py_result(), self.self_object.py_result(), @@ -7550,7 +7550,7 @@ class UnboundMethodNode(ExprNode): def generate_result_code(self, code): class_cname = code.pyclass_stack[-1].classobj.result() code.putln( - "%s = PyMethod_New(%s, 0, %s); %s" % ( + "%s = __Pyx_PyMethod_New(%s, 0, %s); %s" % ( self.result(), self.function.py_result(), class_cname, diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c index 1d913dd28..174de4c8d 100644 --- a/Cython/Utility/CythonFunction.c +++ b/Cython/Utility/CythonFunction.c @@ -545,13 +545,12 @@ static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObj if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { if (type == NULL) type = (PyObject *)(Py_TYPE(obj)); - return PyMethod_New(func, - type, (PyObject *)(Py_TYPE(type))); + return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; - return PyMethod_New(func, obj, type); + return __Pyx_PyMethod_New(func, obj, type); } static PyObject* diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index a0741fde6..51bb02969 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -168,7 +168,13 @@ #endif #if PY_MAJOR_VERSION >= 3 - #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #ifndef PyMethod_New + /* for backwards compatibility only, but PyPy redefines PyMethod_New unconditionally */ + #define PyMethod_New(func, self, klass) __Pyx_PyMethod_New(func, self, klass) + #endif +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif /* inline attribute */ |