From 4f3fe3da7ebfc1b7a1cc88fbc3f0ebfbd1973aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Hern=C3=A1ndez-Cabronero?= Date: Wed, 7 Jun 2023 02:15:35 +0200 Subject: [PATCH] Fixed bug that crashed dill when a module has its __file__ attribute set to None (#598) --- dill/_dill.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dill/_dill.py b/dill/_dill.py index db72d179..7be180e5 100644 --- a/dill/_dill.py +++ b/dill/_dill.py @@ -1612,6 +1612,7 @@ def save_weakproxy(pickler, obj): def _is_builtin_module(module): if not hasattr(module, "__file__"): return True + if module.__file__ is None: return False # If a module file name starts with prefix, it should be a builtin # module, so should always be pickled as a reference. names = ["base_prefix", "base_exec_prefix", "exec_prefix", "prefix", "real_prefix"]