summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2016-12-05 06:47:55 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2016-12-05 06:47:55 (GMT)
commit19d246745d9d013c12e9560dd020d778381780fb (patch)
treea296697991d1f411c3ee76690c6549985744e85a /Doc/whatsnew
parent71c62e14aa27d73623427a0a626b1f20df309e43 (diff)
downloadcpython-19d246745d9d013c12e9560dd020d778381780fb.zip
cpython-19d246745d9d013c12e9560dd020d778381780fb.tar.gz
cpython-19d246745d9d013c12e9560dd020d778381780fb.tar.bz2
Issue #23722: improve __classcell__ compatibility
Handling zero-argument super() in __init_subclass__ and __set_name__ involved moving __class__ initialisation to type.__new__. This requires cooperation from custom metaclasses to ensure that the new __classcell__ entry is passed along appropriately. The initial implementation of that change resulted in abruptly broken zero-argument super() support in metaclasses that didn't adhere to the new requirements (such as Django's metaclass for Model definitions). The updated approach adopted here instead emits a deprecation warning for those cases, and makes them work the same way they did in Python 3.5. This patch also improves the related class machinery documentation to cover these details and to include more reader-friendly cross-references and index entries.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.6.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
index 5b5884d..040a533 100644
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -351,6 +351,11 @@ whenever a new subclass is created::
class Plugin2(PluginBase):
pass
+In order to allow zero-argument :func:`super` calls to work correctly from
+:meth:`~object.__init_subclass__` implementations, custom metaclasses must
+ensure that the new ``__classcell__`` namespace entry is propagated to
+``type.__new__`` (as described in :ref:`class-object-creation`).
+
.. seealso::
:pep:`487` -- Simpler customization of class creation
@@ -2235,6 +2240,11 @@ Changes in the Python API
on a ZipFile created with mode ``'r'`` will raise a :exc:`ValueError`.
Previously, a :exc:`RuntimeError` was raised in those scenarios.
+* when custom metaclasses are combined with zero-argument :func:`super` or
+ direct references from methods to the implicit ``__class__`` closure
+ variable, the implicit ``__classcell__`` namespace entry must now be passed
+ up to ``type.__new__`` for initialisation. Failing to do so will result in
+ a :exc:`DeprecationWarning` in 3.6 and a :exc:`RuntimeWarning` in the future.
Changes in the C API
--------------------