From f789f2f216f4cbf3c20e220f80f94fed82a52186 Mon Sep 17 00:00:00 2001 From: King Chung Huang Date: Wed, 8 Jul 2020 12:36:41 -0600 Subject: [PATCH] Check for dynamic module Add a condition while looking up modules to see if the module is registered as dynamic, returning None if so. This means resources belonging to modules registered as dynamic will be treated as if they had no module, or belonged to __main__. --- cloudpickle/cloudpickle.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloudpickle/cloudpickle.py b/cloudpickle/cloudpickle.py index fcad8be4b..6043fd8ab 100644 --- a/cloudpickle/cloudpickle.py +++ b/cloudpickle/cloudpickle.py @@ -234,6 +234,9 @@ def _lookup_module_and_qualname(obj, name=None): if module_name == "__main__": return None + if _is_dynamic_module(module_name): + return None + # Note: if module_name is in sys.modules, the corresponding module is # assumed importable at unpickling time. See #357 module = sys.modules.get(module_name, None)