This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients docs@python, ncoghlan, nikratio, r.david.murray
Date 2013-07-01.02:00:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372644051.25.0.14734030915.issue18334@psf.upfronthosting.co.za>
In-reply-to
Content
I think we should actually go further, and explicitly defer to http://docs.python.org/3/library/types#dynamic-type-creation for dynamic type creation.

Type shouldn't be called with arbitrary bases any more, precisely *because* doing so breaks __prepare__ handling. It's only safe to call a metaclass directly with arbitrary bases if you call types.prepare_class first:

    mcl, namespace, kwds = types.prepare_class(name, bases)
    cls = mcl(name, bases, namespace, **kwds)

You can only skip types.prepare_class if you *know* you already have the right metaclass (such as when there aren't any base classes defined).
History
Date User Action Args
2013-07-01 02:00:51ncoghlansetrecipients: + ncoghlan, r.david.murray, nikratio, docs@python
2013-07-01 02:00:51ncoghlansetmessageid: <1372644051.25.0.14734030915.issue18334@psf.upfronthosting.co.za>
2013-07-01 02:00:51ncoghlanlinkissue18334 messages
2013-07-01 02:00:51ncoghlancreate