Allow safe access to the __getattribute__ method of modules#14029
Allow safe access to the __getattribute__ method of modules#14029Carreau merged 2 commits intoipython:mainfrom
__getattribute__ method of modules#14029Conversation
|
@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. |
krassowski
left a comment
There was a problem hiding this comment.
LGTM, thank you @ccordoba12!
| method_descriptor: Any = type(list.copy) | ||
| module = type(builtins) |
There was a problem hiding this comment.
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.
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.
Technically we don't even support 3.8 anymore, so plenty of new things you can use !
There was a problem hiding this comment.
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