]> granicus.if.org Git - python/commitdiff
Issue 27366: PEP 487 docs updates
authorNick Coghlan <ncoghlan@gmail.com>
Sun, 31 Jul 2016 02:42:49 +0000 (12:42 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Sun, 31 Jul 2016 02:42:49 +0000 (12:42 +1000)
- Porting note for type keyword arg handling
- __init_subclass__ note regarding  metaclass hint

Doc/reference/datamodel.rst
Doc/whatsnew/3.6.rst

index 075f0967e9621d127ed56987d982d4e9176b4621..1b70345b11568011b866b42235f8141f7a7d0e20 100644 (file)
@@ -1672,6 +1672,13 @@ class defining the method.
    The default implementation ``object.__init_subclass__`` does
    nothing, but raises an error if it is called with any arguments.
 
+   .. note::
+
+      The metaclass hint ``metaclass`` is consumed by the rest of the type
+      machinery, and is never passed to ``__init_subclass__`` implementations.
+      The actual metaclass (rather than the explicit hint) can be accessed as
+      ``type(cls)``.
+
    .. versionadded:: 3.6
 
 
index 0d535133cf066c704ac1a2c0a8a523f8c678ee98..45bd7d9d4539e47175999646de1269ecbe0eebb1 100644 (file)
@@ -759,6 +759,15 @@ Changes in the Python API
   <keyword-only_parameter>`.
   (Contributed by Serhiy Storchaka in :issue:`18726`.)
 
+* As part of :pep:`487`, the handling of keyword arguments passed to
+  :class:`type` (other than the metaclass hint, ``metaclass``) is now
+  consistently delegated to :meth:`object.__init_subclass__`. This means that
+  :meth:`type.__new__` and :meth:`type.__init__` both now accept arbitrary
+  keyword arguments, but :meth:`object.__init_subclass__` (which is called from
+  :meth:`type.__new__`) will reject them by default. Custom metaclasses
+  accepting additional keyword arguments will need to adjust their calls to
+  :meth:`type.__new__` (whether direct or via :class:`super`) accordingly.
+
 
 Changes in the C API
 --------------------