471,071 Members | 1,085 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Re: When do I get "multiple bases have instance lay-out conflict"error?

On Mon, Sep 15, 2008 at 6:06 AM, Harish K Vishwanath
<ha************@gmail.comwrote:
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.,
>>>class A(dict,list):
... pass
wouldn't work.
"built-in type" generally means "implemented in C", also sometimes
called "extension type".
>>>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:
>>class Foo(object): pass
....
>>'__module__' in vars(Foo)
True
>>'__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
Sep 16 '08 #1
0 1348

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Rolf Wester | last post: by
3 posts views Thread by Ari Royce Hidayat | last post: by
reply views Thread by Ari Royce Hidayat | last post: by
reply views Thread by Pankaj Jain | last post: by
9 posts views Thread by Mairhtin O'Feannag | last post: by
5 posts views Thread by Charles Packer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.