Skip to content

Commit

Permalink
Issue 27366: PEP 487 docs updates
Browse files Browse the repository at this point in the history
- Porting note for type keyword arg handling
- __init_subclass__ note regarding  metaclass hint
  • Loading branch information
ncoghlan committed Jul 31, 2016
1 parent 07e2a0a commit 607e1c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------
Expand Down

0 comments on commit 607e1c4

Please sign in to comment.