summaryrefslogtreecommitdiffstats
path: root/Doc/reference/datamodel.rst
diff options
context:
space:
mode:
authorananthan-123 <ananthakrishnan15.2001@gmail.com>2020-02-22 17:56:02 (GMT)
committerGitHub <noreply@github.com>2020-02-22 17:56:01 (GMT)
commitfbe2e0bb8a7ee75d0f9d57682436dac7d69e202e (patch)
tree2cdc2bba10976757f959974332b95c619e61d2d1 /Doc/reference/datamodel.rst
parent1c56f8ffad44478b4214a2bf8eb7cf51c28a347a (diff)
downloadcpython-fbe2e0bb8a7ee75d0f9d57682436dac7d69e202e.zip
cpython-fbe2e0bb8a7ee75d0f9d57682436dac7d69e202e.tar.gz
cpython-fbe2e0bb8a7ee75d0f9d57682436dac7d69e202e.tar.bz2
bpo-17422: Language reference should specify restrictions on class namespace (#18559)
The language reference now specifies restrictions on class namespaces. Adapted from a patch by Ethan Furman.
Diffstat (limited to 'Doc/reference/datamodel.rst')
-rw-r--r--Doc/reference/datamodel.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 9520f82..5b3b669 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1946,10 +1946,12 @@ Once the appropriate metaclass has been identified, then the class namespace
is prepared. If the metaclass has a ``__prepare__`` attribute, it is called
as ``namespace = metaclass.__prepare__(name, bases, **kwds)`` (where the
additional keyword arguments, if any, come from the class definition). The
-``__prepare__`` method should be implemented as a :func:`classmethod`.
+``__prepare__`` method should be implemented as a :func:`classmethod`. The
+namespace returned by ``__prepare__`` is passed in to ``__new__``, but when
+the final class object is created the namespace is copied into a new ``dict``.
If the metaclass has no ``__prepare__`` attribute, then the class namespace
-is initialised as an empty ordered mapping.
+is initialised as an empty :func:`dict`.
.. seealso::