From 490fc80e6b494f8ed65f78fc2032d856ec75b8ef Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Fri, 25 Feb 2011 17:03:46 -0300 Subject: [PATCH] fix ticket #562 --- Cython/Compiler/Nodes.py | 2 ++ Cython/Compiler/TypeSlots.py | 2 +- tests/run/ipow_crash_T562.pyx | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index c41c6814..dbc6d47e 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2278,6 +2278,8 @@ class DefNode(FuncDefNode): arg.hdr_type.declaration_code(arg.hdr_cname)) if not self.entry.is_special and sig.method_flags() == [TypeSlots.method_noargs]: arg_code_list.append("CYTHON_UNUSED PyObject *unused") + if (self.entry.scope.is_c_class_scope and self.entry.name == "__ipow__"): + arg_code_list.append("CYTHON_UNUSED PyObject *unused") if sig.has_generic_args: arg_code_list.append( "PyObject *%s, PyObject *%s" diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py index d6bf22e8..4565c7e7 100644 --- a/Cython/Compiler/TypeSlots.py +++ b/Cython/Compiler/TypeSlots.py @@ -603,7 +603,7 @@ PyNumberMethods = ( MethodSlot(ibinaryfunc, "nb_inplace_multiply", "__imul__"), MethodSlot(ibinaryfunc, "nb_inplace_divide", "__idiv__", py3 = False), MethodSlot(ibinaryfunc, "nb_inplace_remainder", "__imod__"), - MethodSlot(ternaryfunc, "nb_inplace_power", "__ipow__"), # NOT iternaryfunc!!! + MethodSlot(ibinaryfunc, "nb_inplace_power", "__ipow__"), # actually ternaryfunc!!! MethodSlot(ibinaryfunc, "nb_inplace_lshift", "__ilshift__"), MethodSlot(ibinaryfunc, "nb_inplace_rshift", "__irshift__"), MethodSlot(ibinaryfunc, "nb_inplace_and", "__iand__"), diff --git a/tests/run/ipow_crash_T562.pyx b/tests/run/ipow_crash_T562.pyx index f231322f..2cba7901 100644 --- a/tests/run/ipow_crash_T562.pyx +++ b/tests/run/ipow_crash_T562.pyx @@ -1,6 +1,21 @@ +class IPOW: + """ + >>> IPOW().__ipow__('a') + a + >>> x = IPOW() + >>> x **= 'z' + z + """ + def __ipow__(self, other): + print ("%s" % other) + cdef class CrashIPOW: """ >>> CrashIPOW().__ipow__('a') + a + >>> x = CrashIPOW() + >>> x **= 'z' + z """ - def __ipow__(self, other, mod): - print "%s, %s" % (other, mod) + def __ipow__(self, other): + print ("%s" % other) -- 2.26.2