From: Stefan Behnel Date: Wed, 21 May 2008 14:48:59 +0000 (+0200) Subject: fix method calls on Cython generated Python classes X-Git-Tag: 0.9.8rc1~11^2~10^2~15^2~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dc9c9ea50c7f1b28c7f9ea66bc8489e2078f3c13;p=cython.git fix method calls on Cython generated Python classes --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index b786bde5..54232257 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2483,7 +2483,7 @@ class UnboundMethodNode(ExprNode): def generate_result_code(self, code): code.putln( - "%s = __Pyx_PyMethod_New(%s, 0, %s); %s" % ( + "%s = PyMethod_New(%s, 0, %s); %s" % ( self.result_code, self.function.py_result(), self.class_cname, diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 29595237..a16410d3 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -416,9 +416,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("#if PY_MAJOR_VERSION >= 3") code.putln(" #define PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)") - code.putln(" #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, klass)") - code.putln("#else") - code.putln(" #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)") + code.putln(" #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)") code.putln("#endif") code.putln("#ifndef __stdcall") diff --git a/tests/run/append.pyx b/tests/run/append.pyx index b73939d3..a5862294 100644 --- a/tests/run/append.pyx +++ b/tests/run/append.pyx @@ -21,16 +21,12 @@ None [1, 2, (3, 4), 5, 6] """ -cdef extern from "Python.h": - ctypedef class __builtin__.list [ object PyListObject ]: - pass - class A: def append(self, x): print u"appending" return x -cdef class B(list): +class B(list): def append(self, *args): for arg in args: list.append(self, arg)