On 13/05/2015 14:25, andrew cooke wrote:
Hi,
The following code worked on Python 3.2, but no longer works in 3.4. Did
something change, or have I always been doing something dumb?
(I realise the code is pointless as is - it's the simplest example I can give
of a problem I am seeing with more complex code).
class Foo:
... def __new__(cls, *args, **kargs):
... print('new', args, kargs)
... super().__new__(cls, *args, **kargs)
...
class Bar(Foo):
... def __init__(self, a):
... print('init', a)
...
Bar(1)
new (1,) {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in __new__
TypeError: object() takes no parameters
What I was expecting to happen (and what happens in 3.2) is that the
object.__new__ method passes the argument to the __init__ of the subclass.
Any help appreciated.
Thanks,
Andrew
I'm completely convinced that I've seen a change go through on the bug
tracker that impacts on this area, but many months if not years ago.
Unfortunately searching the bug tracker for super, __new__, __init__ and
so on gets a lot of hits, leaving my Mk1 eyeballs overworked. At least
I've tried but sorry, had to give up :(
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list