Why does the following code work fine in Python 2.x and not in Python 3.3+:
class TestA(object):
def __new__(cls, e):
return super(TestA, cls).__new__(TestB, e)
class TestB(TestA):
def __init__(self, e):
print(self, e)
TestA(1)
Python 2.7.6 output:
(<__main__.TestB object at 0x7f6303378ad0>, 1)
Python 3.1.5 output:
__main__:3: DeprecationWarning: object.__new__() takes no parameters
<__main__.TestB object at 0x7f2f69db8f10> 1
Python 3.2.3 and 3.2.5 output:
<__main__.TestB object at 0xcda690> 1
Python 3.3.5 and 3.4.1 output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __new__
TypeError: object() takes no parameters