[Python-checkins] cpython (3.5): #26829: Clarify that namespace is copied to a new __dict__ in instance creation.

r.david.murray python-checkins at python.org
Thu Jun 2 20:06:30 EDT 2016


https://hg.python.org/cpython/rev/754118f8b3ce
changeset:   101628:754118f8b3ce
branch:      3.5
parent:      101624:89abefdebf4d
user:        R David Murray <rdmurray at bitdance.com>
date:        Thu Jun 02 20:05:43 2016 -0400
summary:
  #26829: Clarify that namespace is copied to a new __dict__ in instance creation.

Patch by Emily Morehouse.

files:
  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
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1449,8 +1449,9 @@
    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
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1734,6 +1734,11 @@
 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
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -999,6 +999,7 @@
 Paul Moore
 Ross Moore
 Ben Morgan
+Emily Morehouse
 Derek Morr
 James A Morrison
 Martin Morrison

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list