From 52a9ab170e149489391a0d8b69e05325994d5778 Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Thu, 7 Dec 2017 20:22:55 -0500 Subject: [PATCH 1/4] bpo-8722: DOC: __getattr__ behavior with AttributeError in property --- Doc/reference/datamodel.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 153b58b4fbfbab..769bb9bbf3e355 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1455,10 +1455,13 @@ 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 an attribute lookup has not found the attribute in the usual + places, namely when it is a :func:`property` attribute whose :meth:`__get__` + method raises an :exc:`AttributeError`, when :meth:`__getattribute__` raises + an :exc:`AttributeError` because *name* is not an instance attribute, or + when it is not found in the class tree for ``self``. This method should + 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 From afdce29947e71ed25059adc846e3d93183b0201b Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Fri, 22 Dec 2017 18:56:07 -0500 Subject: [PATCH 2/4] Additional changes --- Doc/reference/datamodel.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 769bb9bbf3e355..d433cea207326d 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1455,13 +1455,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, namely when it is a :func:`property` attribute whose :meth:`__get__` - method raises an :exc:`AttributeError`, when :meth:`__getattribute__` raises - an :exc:`AttributeError` because *name* is not an instance attribute, or - when it is not found in the class tree for ``self``. 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 From b57e459cf4e5e3c3813fa1d0a70ee94fd0c142da Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Sat, 3 Feb 2018 06:11:53 -0500 Subject: [PATCH 3/4] Add blurb --- .../next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst diff --git a/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst b/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst new file mode 100644 index 00000000000000..8ef475ee73a0f2 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst @@ -0,0 +1,2 @@ +Document :meth:`__getattr__` behavior with :exc:`AttributeError` in property +:meth:`get`. From 07b4b5bd0f19cb28203c0f242bb2703fd5338041 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sat, 3 Feb 2018 14:02:34 -0500 Subject: [PATCH 4/4] Update 2018-02-03-06-11-37.bpo-8722.MPyVyj.rst --- .../Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst b/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst index 8ef475ee73a0f2..36e6ff7db3cef8 100644 --- a/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst +++ b/Misc/NEWS.d/next/Documentation/2018-02-03-06-11-37.bpo-8722.MPyVyj.rst @@ -1,2 +1,2 @@ -Document :meth:`__getattr__` behavior with :exc:`AttributeError` in property -:meth:`get`. +Document :meth:`__getattr__` behavior when property :meth:`get` method +raises :exc:`AttributeError`.