Terry Reedy <tjre...@udel.edu> wrote: > Nick Craig-Wood wrote: > > I've noticed with latest python 3.1 checkout (68631) if I have this > > object hierarchy with a default __init__ in the superclass to be used > > by the subclasses which don't necessarily need an __init__ it blows up > > with a TypeError. > > > > class Field(object): > > object is default baseclass, hence not needed
Agreed, but I wanted the code to run with py < 3 also! > > def __init__(self, data): > > """Default init for the subclasses""" > > print("init class=%r, self=%r" % (self.__class__.__name__, self)) > > super(Field, self).__init__(data) > > This line is the problem: remove it and I believe all is fine. > Since object()s are immutable, its init cannot do anything as far as I > know. Deleting this is effectively what you did below. Yes you are absolutely right - that super is never needed. I don't know what I was thinking of! Without that the problem disappears. [snip] > Perhaps 2.5's object.__init__ just swallowed all args, thus hiding bogus > calls. Yes it did which is the fundamental difference in behaviour between py2 and py3 as far as I can see. [snip] > Eliminate bad call. Check! (Bashes head against wall!) Thanks Nick -- Nick Craig-Wood <n...@craig-wood.com> -- http://www.craig-wood.com/nick _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com