diff options
author | Alex-Blade <44120047+Alex-Blade@users.noreply.github.com> | 2022-02-16 07:07:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 07:07:34 (GMT) |
commit | 0cb765b2cec9b020224af016a83bf35c45b71932 (patch) | |
tree | e56baf1ed502d969431a3721d58bfb683d9eb705 /Doc/howto/descriptor.rst | |
parent | 4d8a515d193a4c9f3844704f974ddb870d7ee383 (diff) | |
download | cpython-0cb765b2cec9b020224af016a83bf35c45b71932.zip cpython-0cb765b2cec9b020224af016a83bf35c45b71932.tar.gz cpython-0cb765b2cec9b020224af016a83bf35c45b71932.tar.bz2 |
bpo-46730: Add more info to @property AttributeError messages (GH-31311)
On `obj.read_only_property = x`, raise `AttributeError: property 'read_only_property' of 'A' object has no setter`.
Diffstat (limited to 'Doc/howto/descriptor.rst')
-rw-r--r-- | Doc/howto/descriptor.rst | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index f8b1e00..4f6389e 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -991,17 +991,17 @@ here is a pure Python equivalent: if obj is None: return self if self.fget is None: - raise AttributeError(f'unreadable attribute {self._name}') + raise AttributeError(f"property '{self._name}' has no getter") return self.fget(obj) def __set__(self, obj, value): if self.fset is None: - raise AttributeError(f"can't set attribute {self._name}") + raise AttributeError(f"property '{self._name}' has no setter") self.fset(obj, value) def __delete__(self, obj): if self.fdel is None: - raise AttributeError(f"can't delete attribute {self._name}") + raise AttributeError(f"property '{self._name}' has no deleter") self.fdel(obj) def getter(self, fget): @@ -1456,7 +1456,7 @@ attributes stored in ``__slots__``: >>> mark.dept = 'Space Pirate' Traceback (most recent call last): ... - AttributeError: can't set attribute + AttributeError: property 'dept' of 'Immutable' object has no setter >>> mark.location = 'Mars' Traceback (most recent call last): ... |