Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(168552)

Delta Between Two Patch Sets: Doc/reference/datamodel.rst

Issue 23722: During metaclass.__init__, super() of the constructed class does not work
Left Patch Set: Created 3 years ago
Right Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Doc/whatsnew/3.6.rst » ('j') | Python/bltinmodule.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 1
2 .. _datamodel: 2 .. _datamodel:
3 3
4 ********** 4 **********
5 Data model 5 Data model
6 ********** 6 **********
7 7
8 8
9 .. _objects: 9 .. _objects:
10 10
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 passed here are the same as those passed to ``__prepare__``). 1789 passed here are the same as those passed to ``__prepare__``).
1790 1790
1791 This class object is the one that will be referenced by the zero-argument 1791 This class object is the one that will be referenced by the zero-argument
1792 form of :func:`super`. ``__class__`` is an implicit closure reference 1792 form of :func:`super`. ``__class__`` is an implicit closure reference
1793 created by the compiler if any methods in a class body refer to either 1793 created by the compiler if any methods in a class body refer to either
1794 ``__class__`` or ``super``. This allows the zero argument form of 1794 ``__class__`` or ``super``. This allows the zero argument form of
1795 :func:`super` to correctly identify the class being defined based on 1795 :func:`super` to correctly identify the class being defined based on
1796 lexical scoping, while the class or instance that was used to make the 1796 lexical scoping, while the class or instance that was used to make the
1797 current call is identified based on the first argument passed to the method. 1797 current call is identified based on the first argument passed to the method.
1798 1798
1799 .. impl-detail::
1800
1801 In CPython 3.6 and later, the ``__class__`` cell is passed to the metaclass
1802 as a ``__classcell__`` entry in the class namespace. If present, this must
1803 be propagated up to the ``type.__new__`` call in order for the class to be
1804 initialised correctly.
1805
1806 Failing to do so will result in a :exc:`DeprecationWarning` in Python 3.6,
1807 and a :exc:`RuntimeWarning` in the future.
1808
1809 When using the default metaclass :class:`type`, or any metaclass that ultimately
1810 calls ``type.__new__``, the following additional customisation steps are
1811 invoked after creating the class object:
1812
1813 * first, ``type.__new__`` collects all of the descriptors in the class
1814 namespace that define a ``__set_name__`` method
1815 * second, all of these ``__set_name__`` methods are called with the class
1816 being defined and the assigned name of that particular descriptor
1817 * finally, the ``__init_subclass__`` hook is called on the immediate parent of
1818 the new class in its method resolution order
1819
1799 After the class object is created, it is passed to the class decorators 1820 After the class object is created, it is passed to the class decorators
1800 included in the class definition (if any) and the resulting object is bound 1821 included in the class definition (if any) and the resulting object is bound
1801 in the local namespace as the defined class. 1822 in the local namespace as the defined class.
1802 1823
1803 When a new class is created by ``type.__new__``, the object provided as the 1824 When a new class is created by ``type.__new__``, the object provided as the
1804 namespace parameter is copied to a new ordered mapping and the original 1825 namespace parameter is copied to a new ordered mapping and the original
1805 object is discarded. The new copy is wrapped in a read-only proxy, which 1826 object is discarded. The new copy is wrapped in a read-only proxy, which
1806 becomes the :attr:`~object.__dict__` attribute of the class object. 1827 becomes the :attr:`~object.__dict__` attribute of the class object.
1807 1828
1808 .. seealso:: 1829 .. seealso::
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 2570
2550 .. [#] "Does not support" here means that the class has no such method, or 2571 .. [#] "Does not support" here means that the class has no such method, or
2551 the method returns ``NotImplemented``. Do not set the method to 2572 the method returns ``NotImplemented``. Do not set the method to
2552 ``None`` if you want to force fallback to the right operand's reflected 2573 ``None`` if you want to force fallback to the right operand's reflected
2553 method—that will instead have the opposite effect of explicitly 2574 method—that will instead have the opposite effect of explicitly
2554 *blocking* such fallback. 2575 *blocking* such fallback.
2555 2576
2556 .. [#] For operands of the same type, it is assumed that if the non-reflected me thod 2577 .. [#] For operands of the same type, it is assumed that if the non-reflected me thod
2557 (such as :meth:`__add__`) fails the operation is not supported, which is why the 2578 (such as :meth:`__add__`) fails the operation is not supported, which is why the
2558 reflected method is not called. 2579 reflected method is not called.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+