solving the metaclass conflict

David Mertz mertz at gnosis.cx
Sun Jun 8 18:02:23 EDT 2003


mis6 at pitt.edu (Michele Simionato) wrote previously:
|> Of course:
|>     M = _generatemetaclass((),(A,B,C),0)
|>     #-> TypeError: MRO conflict among bases B, C, A
|> Which is a bad thing.  Is that the real concern?

|Of course not, since this is an issue with the C3 method resolution
|order (http://www.python.org/2.3/mro.html) which in principle has
|nothing to do with metaclasses.

Yes and no.  I know that MRO conflicts don't have anything to do with
metaclasses per se.  But if a version of _generatemetaclass() happened
to remove all the extraneous superclasses from the metabases tuple, that
would make many (all?) MRO conflicts do away.

I think removing those extra superclasses would be a good thing.  But I
don't feel strongly; and there might be some reason I have overlooked
why it wouldn't be so good.

|class C(object,type): pass
|gives a MRO conflict (under Python 2.3).

Hmmm... actually, the question never came to my mind.  I'm not sure what
my first guess would have been--especially since, as you hint, Python
2.2 behaves differently.  Just a little more for readers:

  class C(type, object): pass

Is perfectly happy under both 2.2 and 2.3.  Again, obvious to Michele,
but probably not to some other readers.

Yours, David...

--
 mertz@   _/_/_/_/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY:_/_/_/_/ v i
gnosis  _/_/                    Postmodern Enterprises         _/_/  s r
.cx    _/_/  MAKERS OF CHAOS....                              _/_/   i u
      _/_/_/_/_/ LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU_/_/_/_/_/    g s






More information about the Python-list mailing list