This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: __ipow__ broken for new-style classes
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: aschmolck, gvanrossum
Priority: normal Keywords:

Created on 2002-10-08 12:10 by aschmolck, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (3)
msg12637 - (view) Author: Alexander Schmolck (aschmolck) Date: 2002-10-08 12:10
class NewKlass(object):
    def __ipow__(self, i):
        self._ipow = i
        return self 
obj = NewKlass()
obj **= 1

TypeError: __ipow__() takes exactly 2 arguments (3 given)
msg12638 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-10-13 14:14
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.
msg12639 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-10-15 00:57
Logged In: YES 
user_id=6380

Fixed in 2.3.
History
Date User Action Args
2022-04-10 16:05:44adminsetgithub: 37282
2002-10-08 12:10:58aschmolckcreate