[ python-Bugs-1294232 ] Error in metaclass search order

SourceForge.net noreply at sourceforge.net
Mon Sep 19 01:04:51 CEST 2005


Bugs item #1294232, was opened at 2005-09-18 01:07
Message generated for change (Comment added) made by rodsenra
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1294232&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Type/class unification
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Pedro Werneck (pwerneck)
Assigned to: Nobody/Anonymous (nobody)
Summary: Error in metaclass search order

Initial Comment:
In a simple class hierarchy, I have class A with
metaclass M_A and class B, subclass of A, with
metaclass M_B, subclass of M_A, as required.

A new class C, subclass of B, must have M_B or a
subclass of it as subclass, or a TypeError, metaclass
conflict exception is raised. The exception is raised
in a multiple class hierarchy (diamond, trees, etc) or
in a single class hierarchy when using a metaclass with
no relation to M_A and M_B. 

If M_A or type are used as C metaclass, the interpreter
is ignoring dict['__metaclass__'], which has priority
over B.__class__ and using M_B, when it was supposed to
raise TypeError, with the "metaclass conflict" error
message.

More details in attached file.

----------------------------------------------------------------------

Comment By: Rodrigo Dias Arruda Senra (rodsenra)
Date: 2005-09-18 23:04

Message:
Logged In: YES 
user_id=9057

I have discussed this at length with Pedro Werneck by email.
I personally believe the best path to follow is to document
that 
the entity specified in  __metaclass__ inside C class body, can
be automagically replaced by the most specialized metaclass
among
the metaclasses associated to C ancestors. I think that will
suffice for
the meta-adventurous.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1294232&group_id=5470


More information about the Python-bugs-list mailing list