-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Allow safe access to the __getattribute__
method of modules
#14029
Conversation
@krassowski, I don't understand very well how to add a test for this, so I'd appreciate your guidance for that. |
This restores code completions of second-level modules when Jedi completions are disabled.
Maybe something like: def test_module_access():
import sys
context = limited(sys=sys)
assert guarded_eval("sys.copyright", context) == sys.copyright
context = minimal(sys=sys)
with pytest.raises(GuardRejection):
guarded_eval("sys.copyright", context) in |
Thanks @krassowski! I implemented the same test but using Numpy because I think it's a more important use case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @ccordoba12!
method_descriptor: Any = type(list.copy) | ||
module = type(builtins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum,
I missed that in the previous PR but those should likely be :
from types import MethodDescriptorType
from types import ModuleType
Not blocking so let's open as another issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, MethodDescriptorType
is neat. I missed it being added in 3.7, but since we are not supporting 3.6 for some time now this is good idea indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we don't even support 3.8 anymore, so plenty of new things you can use !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take care of this.
@Carreau, could this fix be backported to the |
meeseeksdev backport to 8.12.x |
…` method of modules
This restores code completions of second-level modules when Jedi completions are disabled.
Fixes #14028