[ python-Bugs-963246 ] Multiple Metaclass inheritance limitation
SourceForge.net
noreply at sourceforge.net
Sun May 30 15:52:23 EDT 2004
Bugs item #963246, was opened at 2004-05-30 11:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=963246&group_id=5470
Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Nobody/Anonymous (nobody)
Summary: Multiple Metaclass inheritance limitation
Initial Comment:
I'm not sure if this constitutes a bug or a limitation
(which should be documented?), but the following
doesn't work with Python 2.3.4.
Assume CMeta is a type defined in C, with
tp_base = PyType_Type
tp_new = some C function which uses the mro to
call the inherited tp_new
tp_flags includes Py_TPFLAGS_BASETYPE
class PyMeta(type):
def __new__(meta, name, bases, attrs):
return super(PyMeta, meta).__new__(meta,
name, bases, attrs)
class MetaTest(CMeta, PyMeta):
pass
class Test:
__metaclass__ = MetaTest
The attempt to define Test generates a
TypeError: "type.__new__(MetaTest) is not safe, use
CMeta.__new__()".
The above error is generated (in tp_new_wrapper) by
the super call in PyMeta.__new__, but this is only
reached as a result of an initial call to CMeta.tp_new
(which, using the mro to find the next "__new__"
method, finds and calls PyMeta.__new__).
It may be there is no good way to allow the above
scenario, but I just thought I'd point it out in case
someone can think of a workaround.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=963246&group_id=5470
More information about the Python-bugs-list
mailing list