From: Mike C. F. <mcf...@ge...> - 2002-01-30 22:36:43
|
That particular example still works fine in 2.2 (it's even seen in the tutorial on type/class unification) ( http://www.python.org/2.2/descrintro.html#cooperation ). >>> class A: ... def m( self ): pass ... >>> class B(A): ... def m( self ): return A.m( self ) ... >>> class C( B ): ... def m( self ): return A.m( self ) ... >>> c = C() >>> c.m() >>> import sys >>> sys.version '2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)]' >>> It's a fairly core semantic that an instance of a sub-class should always be considered an instance of the base-class, no matter how far down the chain it is. When that changes I'll submit a bug report to Python 2.2, rather than Boa ;) . The error comes from the following, I think: http://www.python.org/2.2/descrintro.html#incompatibilities class A: def foo(self): pass class B(A): pass class C(A): def foo(self): B.foo(self) That is, two classes, both of which inherit from A, but _not_ in series (i.e. both inherit from A, but they don't inherit from each other). The error now caught is calling _across_ the parallel hierarchy. You probably knew that and just mis-typed in the email, but thought I should make sure :) . Enjoy, Mike Riaan Booysen wrote: > Hi Mike, these are bugs in Boa. > > This is what's happening: > > class A: > def m(self): pass > > class B(A): > def m(self): A.m(self) > > class C(B): > def m(self): A.m(self) > > c = C() > c.m() > > This snippet use to be work under Python >= 2.1 (although it is usually > a copy paste error) but doesn't under Python 2.2. > > As I've said on the Boa list, I hope to release Boa 0.1.1 soon, as there > are a few places in the code base this problem occurs. _______________________________________ Mike C. Fletcher http://members.rogers.com/mcfletch/ |