Skip to content

Commit ca0bb8b

Browse files
committed
Fix pickling when pytest is loaded.
Older versions of pytest will add a "None" module to sys.modules.
1 parent d986894 commit ca0bb8b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cloudpickle/cloudpickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def _save_subimports(self, code, top_level_dependencies):
384384
# check if the package has any currently loaded sub-imports
385385
prefix = x.__name__ + '.'
386386
for name, module in sys.modules.items():
387-
if name.startswith(prefix):
387+
if name is not None and name.startswith(prefix):
388388
# check whether the function can address the sub-module
389389
tokens = set(name[len(prefix):].split('.'))
390390
if not tokens - set(code.co_names):

0 commit comments

Comments
 (0)