Don't crash when inspecting unsafe properties#454
Closed
AdamNiederer wants to merge 2 commits intopallets-eco:masterfrom
Closed
Don't crash when inspecting unsafe properties#454AdamNiederer wants to merge 2 commits intopallets-eco:masterfrom
AdamNiederer wants to merge 2 commits intopallets-eco:masterfrom
Conversation
If a class property is programmatically computed, it could potentially throw an exception when run in this context. In that case, just move on to the next property instead of crashing the entire application.
|
|
||
| for name in dir(base): | ||
| attr = getattr(base, name) | ||
| attr = getattr(base, name, None) |
There was a problem hiding this comment.
where is the unittest that demonstrates that this helps
as far as i understood getattr will still fail in basically all computing exceptions (and rightfully so)
Author
There was a problem hiding this comment.
I came across this when Flask-SQLAlchemy was accessing a class property reliant on the name of the subclass in an abstract superclass as the superclass.
This fix catches AttributeErrors that may arise from Flask-SQLAlchemy's handling of abstract mixins, but would never be thrown in the program at runtime. We could change the way it handles abstract superclasses, but this fix is six characters and I can't think of any other problems which might arise from its current behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
If a class property is programmatically computed, it could potentially
throw an exception when run in this context. In that case, just move
on to the next property instead of crashing the entire application.