[Python-bugs-list] [ python-Bugs-699934 ] Obscure error message

SourceForge.net noreply@sourceforge.net
Thu, 13 Mar 2003 22:34:06 -0800


Bugs item #699934, was opened at 2003-03-08 07:29
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=699934&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Bjorn Pettersen (bpettersen)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Obscure error message

Initial Comment:
>>> class A(object):
...   m = 1
...
>>> class B(A): pass
...
>>> class C(A): pass
...
>>> class D(A,B): pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: MRO conflict among bases A, B

I happen to know what MRO stands for, but probably 
most people that made the typo I did in the diamond 
inheritance graph will have no idea what they did wrong...

How about "One of the declared superclasses A, B 
inherits from the other, the method resolution order 
(MRO) would therefore be undefined. Cannot create 
class."

-- bjorn


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-03-14 01:34

Message:
Logged In: YES 
user_id=80475

Idea 1
------
TypeError: Cannot create class.  
Accessing superclasses A, B in order creates conflicting
inheritance trees which leave the method resolution order 
(MRO) undefined.

Idea 2
------
Cannot create a consistent method resolution order (MRO) 
for bases A, B.

Idea 3
------
Doh!

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2003-03-12 08:01

Message:
Logged In: YES 
user_id=6656

Unfortunately the new error message makes no sense when you
get it by rearranging __bases__.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-03-11 23:38

Message:
Logged In: YES 
user_id=80475

Fixed.  See:

Objects/typeobject.c 2.216
Lib/test/test_descr.py 1.187


----------------------------------------------------------------------

Comment By: Bjorn Pettersen (bpettersen)
Date: 2003-03-11 21:50

Message:
Logged In: YES 
user_id=556638

Even better. If I were to suggest anything, it would be to 
add "(lookup)" after "resolution" since that seems to be the 
more frequently used terminology -- not a big issue though.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-03-11 20:29

Message:
Logged In: YES 
user_id=80475

I don't think the first part of the sentence is accurate.
MRO conflicts can arise for less straight-forward reasons.
How about:

"Cannot create class.  Superclasses A, B have conflicting 
inheritance trees which leave the method resolution order 
(MRO) undefined."


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=699934&group_id=5470