[Python-ideas] Suggestion: Deprecate metaclasses that are not instances of type

Neil Girdhar mistersheik at gmail.com
Thu Oct 13 19:52:11 EDT 2016


Bug: http://bugs.python.org/issue28437

On Thu, Oct 13, 2016 at 7:15 PM Neil Girdhar <mistersheik at gmail.com> wrote:

> That's fair.  However, the documentation should at least be repaired by
> replacing section 3.3.3.2 with:
>
> "The metaclass of a class definition is selected from the explicitly
> specified metaclass (if any) and the metaclasses (i.e. type(cls)) of all
> specified base classes. The most derived metaclass is one which is a
> subtype of all of these candidate metaclasses. If none of the candidate
> metaclasses meets that criterion, then the class definition will fail with
> TypeError. If provided, the explicit metaclass must be a callable accepting
> the positional arguments (name, bases, _dict)."
>
> This is because something happened along the way and Objects/typeobject.c:
> type_new no longer coincides with Lib/types.py:new_class.  The Python
> version conditionally calls _calculate_meta whereas the C version calls it
> unconditionally.  I consider the C implementation to be the "correct"
> version.
>
> Best,
>
> Neil
>
> On Thu, Oct 13, 2016 at 5:41 PM Steven D'Aprano <steve at pearwood.info>
> wrote:
>
> On Thu, Oct 13, 2016 at 01:46:34PM -0700, Neil Girdhar wrote:
>
> > If provided, the explicit metaclass must be an instance of
> > type()."
>
> -1 for pointless breakage.
>
> The metaclass has always been permitted to be any callable. You haven't
> given any good reason for gratuitously changing this.
>
>
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/wrHDM0SOIqE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161013/95ad9fcf/attachment.html>


More information about the Python-ideas mailing list