Subtle error in `getattr_hook` example in the Descriptor Guide
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Documentation
The example below, from the Descriptor Guide, does not seem to reflect the behaviour of the actual implementation.
Unless I'm mistaken, line 736 return obj.__getattribute__(name) should actually read return type(obj).__getattribute__(obj, name).
It's easy to miss when thinking of class instances, but the issue becomes more evident when the example is applied to an attribute lookup on a class object instead. The example would call the __getattribute__ method of the class itself, while the actual implementation calls __getattribute__ on the metaclass (not to mention that in this case the call in the example would fail, due to a missing argument, as it is calling a plain function, rather than a bound method).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open Doc/howto/descriptor.rst around lines 733-740 and compare the getattr_hook example with the implementation behavior described in the issue, especially for class-object attribute lookup. If the discrepancy is confirmed, update the documented return expression and verify that the guide matches the implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100