So does this exception come with a map, and some food?

I ran across this exception again today during some reading – and when I first hit it some time ago, I gave it the label of “best python error” (and put it in a bugzilla quip list).


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

Every time I read this error, my brain convulses and I suddenly find that it’s 3 hours later and I’m not wearing pants.

Seriously: this error could be better done as:


TypeError: You're doomed!
1> Open the chest
2> back out of the room slowly
3> attack the ogre

Of course, I’m being sarcastic for those of you with a broken laugh-o-meter.

I just thought about something – what if you made error messages “realer” like:

IOError: you can not access that thingie right now, it's either not on disk, unavailable - or your stupid USB disk powered off again nubcakes


MemoryError: How in the hell did you do this in a language with GC? Stop it. STOP. OH GOD IT BUR (oomkill from kernel)

  • Pawel Murias
    The error sounds perfectly reasonable if you know what metaclasses are and provided it's an issue with them
  • ROFL that's awesome.
  • Doug Napoleone
    The error thrown need only be one order of magnitude easier to understand than the language feature you are using which is causing the problem. Given that this is python metaclasses we are talking about, I would say that the error message is much clearer than expected ;-)

    I cant remember where I last saw this error, but it was eather caused by multiple inheritance (with metaclasses and improper super use when dealing with them), and/or mixing old and new style classes with metaclasses. Remember your (object).

    I would be interested to see the code causing the problem, and what the actual issue is.
    But then again, I don't think I want to hurt my head like that....
  • Yes, this stems from fubaring your inheritance/metaclasses. Interestingly enough plug/ there was a pymag article this past month trying to demystify metaclasses: I highly recommend it /plug. Of course, you're right - the error should match the difficulty of the code.

    Of course, where does that put something like threading? "Error: No, don't share state, you're screwed anyways. Quit now" :)
blog comments powered by Disqus