Skip to content

Commit 9ae8d9f

Browse files
committed
[3.6] bpo-30354: Update data model documentation for super() (pythonGH-1561)
The data model section of the language reference was written well before the zero-argument form of super() was added. To avoid giving the impression that they're doing something unusual, this updates the description of `__new__` and `__init__` to use the zero-argument form. Patch by Cheryl Sabella. (cherry picked from commit 12b1c18)
1 parent 00b381b commit 9ae8d9f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎Doc/reference/datamodel.rst‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,9 @@ Basic customization
11191119
(usually an instance of *cls*).
11201120

11211121
Typical implementations create a new instance of the class by invoking the
1122-
superclass's :meth:`__new__` method using ``super(currentclass,
1123-
cls).__new__(cls[, ...])`` with appropriate arguments and then modifying the
1124-
newly-created instance as necessary before returning it.
1122+
superclass's :meth:`__new__` method using ``super().__new__(cls[, ...])``
1123+
with appropriate arguments and then modifying the newly-created instance
1124+
as necessary before returning it.
11251125

11261126
If :meth:`__new__` returns an instance of *cls*, then the new instance's
11271127
:meth:`__init__` method will be invoked like ``__init__(self[, ...])``, where
@@ -1145,7 +1145,7 @@ Basic customization
11451145
class constructor expression. If a base class has an :meth:`__init__`
11461146
method, the derived class's :meth:`__init__` method, if any, must explicitly
11471147
call it to ensure proper initialization of the base class part of the
1148-
instance; for example: ``BaseClass.__init__(self, [args...])``.
1148+
instance; for example: ``super().__init__([args...])``.
11491149

11501150
Because :meth:`__new__` and :meth:`__init__` work together in constructing
11511151
objects (:meth:`__new__` to create it, and :meth:`__init__` to customize it),
@@ -1578,8 +1578,8 @@ Class Binding
15781578
``A.__dict__['x'].__get__(None, A)``.
15791579

15801580
Super Binding
1581-
If ``a`` is an instance of :class:`super`, then the binding ``super(B,
1582-
obj).m()`` searches ``obj.__class__.__mro__`` for the base class ``A``
1581+
If ``a`` is an instance of :class:`super`, then the binding ``super(B, obj).m()``
1582+
searches ``obj.__class__.__mro__`` for the base class ``A``
15831583
immediately preceding ``B`` and then invokes the descriptor with the call:
15841584
``A.__dict__['m'].__get__(obj, obj.__class__)``.
15851585

0 commit comments

Comments
 (0)