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 gmt
Recipients gmt
Date 2014-12-03.03:06:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1417575996.27.0.0377229521666.issue22968@psf.upfronthosting.co.za>
In-reply-to
Content
> perhaps "isinstance(x, type)" should have been "issubclass(x, type)" to correctly capture how python 2 does it.

Actually, scratch that -- its a brain fart.

IIUC new_class was created because, at the time, there was no exposed turnkey method to execute the PEP3115 protocol... if that's right, is it worth considering, now that __build_class__ is exposed, a reimplementation like:

def _pass(ns): pass

def new_class(name, bases=(), kwds={}, exec_body=_pass):
    __build_class__(exec_body, name, *bases, **kwds)

?  But this is the wrong place to ask.

...

BTW, since my original post I've figured out a bunch of things, or think I have:

* new_class should model __build_class__

* __build_class__ need not model type_new in terms of what it allows.

I think point one is what was confusing me before.

It is perhaps worth asking, if the differences between type_new and __build_class__ make sense, given that python 3's type_new is stricter than python 2's?  I think I've figured that out too:

A given (metatype, bases) tuple may be sensibly used to implement the PEP3115 protocol only if either:

  A) it can be proved that type_new will return NULL if it
     is invoked like type_new(metatype, name, bases,...), or,

  B) it can be proved that type_new, when invoked like
     type_new(metatype, name, bases, ...), will use metatype,
     and not some other (e.g., more derived) type, as the tp_base
     of the thing it creates, in the event that it does not return NULL.

If the above is falsified, we pretty clearly have a situation where build_type has used the wrong metaclass.

But the fact that __build_class__ is more liberal than type_new is not a problem from the perspective of type_new -- indeed it's a feature, and I'm now satisfied that the above constraint holds.

I've attached a new patch, this time I tested it.
History
Date User Action Args
2014-12-03 03:06:36gmtsetrecipients: + gmt
2014-12-03 03:06:36gmtsetmessageid: <1417575996.27.0.0377229521666.issue22968@psf.upfronthosting.co.za>
2014-12-03 03:06:36gmtlinkissue22968 messages
2014-12-03 03:06:34gmtcreate