From dd4fcf52f41116479c8d337b0dcfae2287d6ae4d Mon Sep 17 00:00:00 2001 From: R David Murray Date: Thu, 2 Jun 2016 20:05:43 -0400 Subject: #26829: Clarify that namespace is copied to a new __dict__ in instance creation. Patch by Emily Morehouse. --- Doc/library/functions.rst | 5 +++-- Doc/reference/datamodel.rst | 5 +++++ Misc/ACKS | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 89b2ac6..c3563f3 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1449,8 +1449,9 @@ are always available. They are listed here in alphabetical order. class name and becomes the :attr:`~class.__name__` attribute; the *bases* tuple itemizes the base classes and becomes the :attr:`~class.__bases__` attribute; and the *dict* dictionary is the namespace containing definitions - for class body and becomes the :attr:`~object.__dict__` attribute. For - example, the following two statements create identical :class:`type` objects: + for class body and is copied to a standard dictionary to become the + :attr:`~object.__dict__` attribute. For example, the following two + statements create identical :class:`type` objects: >>> class X: ... a = 1 diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 2b59ce1..3ddbd62 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1734,6 +1734,11 @@ After the class object is created, it is passed to the class decorators included in the class definition (if any) and the resulting object is bound in the local namespace as the defined class. +When a new class is created by ``type.__new__``, the object provided as the +namespace parameter is copied to a standard Python dictionary and the original +object is discarded. The new copy becomes the :attr:`~object.__dict__` attribute +of the class object. + .. seealso:: :pep:`3135` - New super diff --git a/Misc/ACKS b/Misc/ACKS index bfdc447..0da5cf8 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -999,6 +999,7 @@ Peter Moody Paul Moore Ross Moore Ben Morgan +Emily Morehouse Derek Morr James A Morrison Martin Morrison -- cgit v0.12