Fix propagation of AttributeErrors raised by exposed descriptors #479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #478.
This uses
inspect.getattr_static
to avoid triggering the descriptor lookup thathasattr
usually triggers. The logic also needs a fallback tohasattr
sincegetattr_static
"may not be able to retrieve all attributes thatgetattr
can fetch (like dynamically created attributes)".Per the docs,
getattr_static
"may find attributes thatgetattr
can’t (like descriptors that raiseAttributeError
)". I am not aware of any edge cases wherehasattr
will return False but wheregetattr_static
will succeed without raising anAttributeError
(although I did not not dive into CPython'sgetattr_static
implementation to look for such cases), but perhaps there is some edge case that makes usinggetattr_static
a bad choice here. If you know of a better way to fix #478 please let me know :)I was a bit liberal with adding the tests for multiple configs since the runtime it adds is negligible and extra safety is good. I also slightly broke PEP 8 line length in the tests I added—please change my code style if RPyC uses a different style :)