This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Paul Pinterits, cryvate, docs@python, iritkatriel, rhettinger
Date 2021-12-04.01:44:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638582252.44.0.0747756989777.issue31735@roundup.psfhosted.org>
In-reply-to
Content
> it should have
>
> d.__get__(obj, type(obj)) instead of d.__get__(obj)


The objtype argument is optional as shown in all of the examples.  The call from object.__getattribute__() always passes in both parameters, even though only the first is required.
  
    ################################################################
    # Demonstration of __get__() being called with one or two params

    class A:
        def __init__(self, x):
            self.x = x
        def m(self, y):
            return self.x * y

    >>> a = A(10)
    >>> a.m(5)
    50
    >>> vars(A)['m'].__get__(a)(5)     # objtype is not required
    50
    >>> vars(A)['m'].__get__(a, A)(5)  # objtype may be used
    50


    ################################################################
    # Demonstration of object.__getattribute__ supplying both args

    class Desc:
        def __get__(self, *args):
            return args
      
    class B:
        z = Desc()
     
    >>> b = B()
    >>> b.z
    (<__main__.B object at 0x109156110>, <class '__main__.B'>)
History
Date User Action Args
2021-12-04 01:44:12rhettingersetrecipients: + rhettinger, docs@python, Paul Pinterits, cryvate, iritkatriel
2021-12-04 01:44:12rhettingersetmessageid: <1638582252.44.0.0747756989777.issue31735@roundup.psfhosted.org>
2021-12-04 01:44:12rhettingerlinkissue31735 messages
2021-12-04 01:44:12rhettingercreate