On Mon, Sep 15, 2008 at 6:06 AM, Harish K Vishwanath
<harish.shastry@gmail.comwrote:
Quote:
Hello all,
>
When do we actually see the error :
>
TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict
>
>
I searched the web and I could not find a correct guideline as to when such
an error could arise. One of the places said that "A new style class cannot
inherit from more than one python built-in class". That is.,
>
Quote:
Quote:
>>>class A(dict,list):
... pass
wouldn't work.
"built-in type" generally means "implemented in C", also sometimes
called "extension type".
Quote:
Quote:
Quote:
>>>class A(Exception,persistent.Persistent):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict
>
Still declaration of class A fails. Any idea? What is the exact rule when
python throws up " multiple bases have instance lay-out conflict" error?
Both the Exception and ZODB Persistent objects are implemented in C,
and they have different ideas for the format of the struct that holds
an object's data. It can be tricky to tell by introspection whether a
new-style class is implemented in Python or C. One possible
heuristic:
Quote:
Quote:
Quote:
>>class Foo(object): pass
....
Quote:
Quote:
Quote:
>>'__module__' in vars(Foo)
True
Quote:
Quote:
Quote:
>>'__module__' in vars(Exception)
False
I'm not sure whether this is valid in all cases. Someone else may
know of a better way.
-Miles