New is_pickled_module() function#556
Conversation
is_pickled_module() function
mmckerns
left a comment
There was a problem hiding this comment.
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.
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.
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()