[pygtk] gobject & metaclasses

Michael Urman murman at gmail.com
Mon Oct 27 01:17:24 WST 2008


On Sun, Oct 26, 2008 at 4:30 AM, Alessandro Dentella <sandro at e-den.it> wrote:
> TypeError: Error when calling the metaclass bases
>    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
>
>
> What does this mean and what should I do instead?

This is actually a generic python question, but to recognize it, you
have to know that GObject has its own metaclass. The similar case in
(shortened) pure python is:

class meta1(type): pass
class meta2(type): pass
class base(meta1): __metaclass__ = meta1
class derv(base): __metaclass__ = meta2

To fix it up, you have to mix the metaclasses (and use real
metaclasses, of course):

class mmeta(meta1, meta2): pass
class derv(base): __metaclass__ = mmeta

-- 
Michael Urman


More information about the pygtk mailing list