New submission from Adi <deepspa...@gmail.com>:

Due to shared code between the 2 and 3 forms of pow, the following code causes 
a TypeError:

class A:
    def __init__(self, val):
        self.val = val
    
    def __ipow__(self, other):
        return NotImplemented

class B:
    def __init__(self, val):
        self.val = val
    
    def __rpow__(self, other):
        return A(other.val ** self.val)

a = A(2)
b = B(2)
a **= b


(https://stackoverflow.com/questions/58141475/ipow-raising-typeerror-when-left-hand-side-object-returns-notimplemented)

----------
components: Interpreter Core
messages: 353419
nosy: DeepSpace
priority: normal
severity: normal
status: open
title: __rpow__ not reached when __ipow__ returns NotImplemented
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to