Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58b799d
Fix wrong Sphinx markup preventing syntax highlighting
geryogam Mar 17, 2021
f77b0f9
Fix a bug in the ClassMethod Python equivalent
geryogam Mar 17, 2021
1dbd876
Fix the description of the ClassMethod Python equivalent
geryogam Mar 17, 2021
d0d301e
Raise TypeError for __get__(None, None) calls
geryogam Mar 19, 2021
e87fe37
Fix a typo
geryogam Mar 22, 2021
52a06d0
Use the existing cls variable
geryogam Mar 25, 2021
2f9971b
Allow keyword arguments in Object.__new__
geryogam Mar 31, 2021
2f335ca
Use two more super() for consistency
geryogam Mar 31, 2021
4886dbb
Add Object.__getattribute__ to raise AttributeError with the correct …
geryogam Mar 31, 2021
705c577
Allow attribute lookup from a class in Member.__get__
geryogam Mar 31, 2021
c0e6432
Allow keyword arguments in Type.__new__
geryogam Mar 31, 2021
81ec93c
Raise ValueError for slot names conflicting with class variables
geryogam Apr 1, 2021
34eef3a
Update descriptor.rst
geryogam Apr 1, 2021
ae8c622
Raise TypeError for non-empty __slots__ in subclasses of variable-len…
geryogam Apr 5, 2021
1d5fb96
Raise TypeError for non-empty __slots__ in subclasses of variable-len…
geryogam Apr 5, 2021
4671b91
Apply requested changes and remove changes on the slots emulation
geryogam May 10, 2022
0a132bf
Merge branch 'main' into patch-14
geryogam May 10, 2022
62fe4fc
Update descriptor.rst
geryogam May 10, 2022
1252f4b
Update descriptor.rst
geryogam May 10, 2022
58ae977
Update descriptor.rst
geryogam May 10, 2022
5630c64
Update descriptor.rst
geryogam May 10, 2022
bfb33f7
Merge branch 'main' into patch-14
geryogam May 10, 2022
5d45eaa
Revert the two-argument form of super() and forward variadic arguments
geryogam Oct 4, 2022
c853e6b
Merge branch 'main' into patch-14
rhettinger Oct 7, 2022
bcc9da0
Update descriptor.rst
geryogam Oct 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow attribute lookup from a class in Member.__get__
  • Loading branch information
geryogam authored Mar 31, 2021
commit 705c577a6d02c205cb2dd5232516a1364cca4b85
8 changes: 5 additions & 3 deletions Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,8 @@ by member descriptors:
# Also see PyMember_GetOne() in Python/structmember.c
if obj is None and objtype is None:
raise TypeError('__get__(None, None) is invalid')
if obj is None:
return self
value = obj._slot_values[self.offset]
if value is null:
raise AttributeError(self.name)
Expand All @@ -1460,7 +1462,7 @@ by member descriptors:

def __repr__(self):
'Emulate member_repr() in Objects/descrobject.c'
return f'<Member {self.name!r} of {self.clsname!r}>'
return f'<Member {self.name!r} of {self.clsname!r} objects>'

The :meth:`type.__new__` method takes care of adding member objects to class
variables:
Expand Down Expand Up @@ -1553,9 +1555,9 @@ At this point, the metaclass has loaded member objects for *x* and *y*::

# We test this separately because the preceding section is not
# doctestable due to the hex memory address for the __init__ function
>>> isinstance(vars(H)['x'], Member)
>>> isinstance(H.x, Member)
True
>>> isinstance(vars(H)['y'], Member)
>>> isinstance(H.y, Member)
True

When instances are created, they have a ``_slot_values`` list where the
Expand Down