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

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:
Left: Side by side diff | Download
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
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 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:: 1799 .. impl-detail::
1800 1800
1801 In CPython 3.6 and later, the ``__class__`` cell is passed to the metaclass 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 1802 as a ``__classcell__`` entry in the class namespace. If present, this must
storchaka 2016/12/04 11:23:35 Would be nice to add __classcell__ to the document
1803 be propagated up to the ``type.__new__`` call in order for the class to be 1803 be propagated up to the ``type.__new__`` call in order for the class to be
1804 initialised correctly. 1804 initialised correctly.
1805 1805
1806 Failing to do so will result in a :exc:`DeprecationWarning` in Python 3.6, 1806 Failing to do so will result in a :exc:`DeprecationWarning` in Python 3.6,
1807 and a :exc:`RuntimeWarning` in the future. 1807 and a :exc:`RuntimeWarning` in the future.
1808 1808
1809 When using the default metaclass :class:`type`, or any metaclass that ultimately 1809 When using the default metaclass :class:`type`, or any metaclass that ultimately
1810 calls ``type.__new__``, the following additional customisation steps are 1810 calls ``type.__new__``, the following additional customisation steps are
1811 invoked after creating the class object: 1811 invoked after creating the class object:
1812 1812
1813 * first, ``type.__new__`` collects all of the descriptors in the class 1813 * first, ``type.__new__`` collects all of the descriptors in the class
1814 namespace that define a ``__set_name__`` method 1814 namespace that define a ``__set_name__`` method
storchaka 2016/12/04 11:23:35 Needed semicolons at the end or a dot after the la
storchaka 2016/12/04 11:23:35 You can use a reference: meth:`~object.__set_
1815 * second, all of these ``__set_name__`` methods are called with the class 1815 * second, all of these ``__set_name__`` methods are called with the class
1816 being defined and the assigned name of that particular descriptor 1816 being defined and the assigned name of that particular descriptor
1817 * finally, the ``__init_subclass__`` hook is called on the immediate parent of 1817 * finally, the ``__init_subclass__`` hook is called on the immediate parent of
storchaka 2016/12/04 11:23:35 You can use a reference: meth:`~object.__init
1818 the new class in its method resolution order 1818 the new class in its method resolution order
1819 1819
1820 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
1821 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
1822 in the local namespace as the defined class. 1822 in the local namespace as the defined class.
1823 1823
1824 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
1825 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
1826 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
1827 becomes the :attr:`~object.__dict__` attribute of the class object. 1827 becomes the :attr:`~object.__dict__` attribute of the class object.
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 2570
2571 .. [#] "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
2572 the method returns ``NotImplemented``. Do not set the method to 2572 the method returns ``NotImplemented``. Do not set the method to
2573 ``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
2574 method—that will instead have the opposite effect of explicitly 2574 method—that will instead have the opposite effect of explicitly
2575 *blocking* such fallback. 2575 *blocking* such fallback.
2576 2576
2577 .. [#] 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
2578 (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
2579 reflected method is not called. 2579 reflected method is not called.
LEFTRIGHT

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