diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-02-05 03:10:00 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2018-02-05 03:10:00 (GMT) |
commit | a8c25d1c7f0d395861cc3e10dd01989150891c95 (patch) | |
tree | 12d9d976ce4528a3f267e78757747d54ddf14b21 /Doc | |
parent | 1c2b138671656abf8563a0cd7ef27c8c2e0be4e6 (diff) | |
download | cpython-a8c25d1c7f0d395861cc3e10dd01989150891c95.zip cpython-a8c25d1c7f0d395861cc3e10dd01989150891c95.tar.gz cpython-a8c25d1c7f0d395861cc3e10dd01989150891c95.tar.bz2 |
[3.6] bpo-8722: Document __getattr__ behavior with AttributeError in property (GH-5542)
When `__getattr__` is implemented, attribute lookup will always fall back to that,
even if the initial failure comes from `__getattribute__` or a descriptor's `__get__`
method (including property methods).
(cherry picked from commit d1f318105b8781b01f3507d5cb0fd841b977d5f2)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/reference/datamodel.rst | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 9752494..773eeb2 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1443,10 +1443,12 @@ access (use of, assignment to, or deletion of ``x.name``) for class instances. .. method:: object.__getattr__(self, name) - Called when an attribute lookup has not found the attribute in the usual places - (i.e. it is not an instance attribute nor is it found in the class tree for - ``self``). ``name`` is the attribute name. This method should return the - (computed) attribute value or raise an :exc:`AttributeError` exception. + Called when the default attribute access fails with an :exc:`AttributeError` + (either :meth:`__getattribute__` raises an :exc:`AttributeError` because + *name* is not an instance attribute or an attribute in the class tree + for ``self``; or :meth:`__get__` of a *name* property raises + :exc:`AttributeError`). This method should either return the (computed) + attribute value or raise an :exc:`AttributeError` exception. Note that if the attribute is found through the normal mechanism, :meth:`__getattr__` is not called. (This is an intentional asymmetry between |