-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError propagation is broken in cached_property with slots=True #1230
Comments
I'm a little confused about what's going on here – are we somehow rewriting ping @diabolo-dan 😇 |
Yeah, as I recall there's some rewriting there to avoid a confusing I think there's a try/except that could be rewritten as an I won't be able to look at it this week, as I'm on holiday, but might be able to take a look when I'm back next week. |
Thanks, and enjoy your holiday! |
In slotted classes' generated __getattr__(), we try __getattribute__() before __getattr__(), if available, and eventually let AttributeError propagate. This matches better with the behaviour described in Python's documentation "Customizing attribute access": https://docs.python.org/3/reference/datamodel.html#customizing-attribute-access Fix python-attrs#1230
In slotted classes' generated __getattr__(), we try __getattribute__() before __getattr__(), if available, and eventually let AttributeError propagate. This matches better with the behaviour described in Python's documentation "Customizing attribute access": https://docs.python.org/3/reference/datamodel.html#customizing-attribute-access Fix python-attrs#1230
* Preserve AttributeError in slotted classes with cached_property In slotted classes' generated __getattr__(), we try __getattribute__() before __getattr__(), if available, and eventually let AttributeError propagate. This matches better with the behaviour described in Python's documentation "Customizing attribute access": https://docs.python.org/3/reference/datamodel.html#customizing-attribute-access Fix #1230 * Update changelog.d/1253.change.md --------- Co-authored-by: Hynek Schlawack <hs@ox.cx>
Let's start with a regular class:
Just as expected. Now let's use attrs with
__dict__
:So far so good. But:
This made me spend quite some time wondering where did my attribute go :)
The text was updated successfully, but these errors were encountered: