[issue1294232] Error in metaclass search order

Daniel Urban report at bugs.python.org
Fri Apr 22 07:41:26 CEST 2011


Daniel Urban <urban.dani+py at gmail.com> added the comment:

Okay, probably the check in my previous patch was too strict (sorry for the noise).  I'm attaching an updated patch again.  Now the algorithm in __build_class__ is this:

1. If an object is explicitly given with the metaclass keyword, that is the "starting metaclass".
2. Else if there are bases, the type of the first base is the starting metaclass (note, that this possibly will be replaced later, but before the __prepare__ call).
3. Else the starting metaclass is type.

4. If the starting metaclass is a class, do the metaclass calculation, so the starting metaclass may be replaced with its most derived descendant.
5. Else we cannot do the metaclass calculation, so use the starting metaclass as is.

There are also tests for these cases, and the example in msg134256 now works too.

----------
Added file: http://bugs.python.org/file21755/issue11256_4.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1294232>
_______________________________________


More information about the Python-bugs-list mailing list