Python - "object Layout"
can somebody describe the following exception? What is the 'object layout' and how it is defined? Thanks Traceback (most recent call last): File 'test_gui.py', line 5, in
Solution 1:
It means that you tried to change the type of an object (by assigning to __bases__
) and the new type wasn't compatible with the old one. This happens when the underlying C data structure isn't the same for both types.
See http://www.mail-archive.com/python-list@python.org/msg52950.html for a list of differences between types that might trigger this exception.
Solution 2:
In my case, the error occurred when I tried to use change the __class__
of an object that also has __slots__
, like this:
class Base:
__slots__ = ('a', 'b', 'c')
class Child(Base):
pass
obj = Base()
obj.__class__ = Child
# -> TypeError: __class__ assignment: 'Child' object layout differs from 'Base'
Post a Comment for "Python - "object Layout""