-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
New is_pickled_module()
function
#556
base: master
Are you sure you want to change the base?
Conversation
is_pickled_module()
function
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.
Looks really nice. Sorry about the delay. Let's have a small think about naming of the function, what it returns, and the naming of importable
kwarg (and it's docs). Otherwise LGTM.
return False | ||
is_runtime_mod = pickle_main.startswith('__runtime__.') | ||
res = importable ^ is_runtime_mod | ||
if res and identify: |
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 think this function could be named pickled_module
or identify_module
, and the identify
kwarg set to always be true and then removed.
|
||
Parameters: | ||
filename: a path-like object or a readable stream. | ||
importable: expected kind of the file's saved module. Use `True` for |
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.
This doc is slightly confusing, especially if people might think that the file itself is importable (without first unpickling). Fundamentally, it's either a file-like module object or a module class instance... so is something in that vein a better name? It's a bit of an unusual thing for people to think about, so lets give the name some extra thought.
From #475 / #527
Also fixes
_identify_module()
-> raises exception for modules saved withdump()