[Python-bugs-list] [ python-Bugs-620179 ] __ipow__ broken for new-style classes

noreply@sourceforge.net noreply@sourceforge.net
Mon, 14 Oct 2002 17:57:41 -0700


Bugs item #620179, was opened at 2002-10-08 08:10
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=620179&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Alexander Schmolck (aschmolck)
Assigned to: Guido van Rossum (gvanrossum)
Summary: __ipow__ broken for new-style classes

Initial Comment:
class NewKlass(object):
    def __ipow__(self, i):
        self._ipow = i
        return self 
obj = NewKlass()
obj **= 1

TypeError: __ipow__() takes exactly 2 arguments (3 given)


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-10-14 20:57

Message:
Logged In: YES 
user_id=6380

Fixed in 2.3.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-10-13 10:14

Message:
Logged In: YES 
user_id=6380

Whoops, you're right. This was there since 2.2.

Unfortunately "fixing" this means broken code that would
have worked before, so I won't fix it in 2.2.2; I'll fix it
in 2.3 though.

Workaround; declare __ipow__ with an *optional* dummy extra
argument, defaulting to None (it will only be called with
None in that position anyway):

def __ipow__(self, i, arg=None): ...

This provides you with forward compatibility in 2.3.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=620179&group_id=5470