diff --git a/lib/python/pyflyby/_modules.py b/lib/python/pyflyby/_modules.py index fb37cdc4..b90fac6b 100644 --- a/lib/python/pyflyby/_modules.py +++ b/lib/python/pyflyby/_modules.py @@ -7,6 +7,7 @@ import ast from functools import total_ordering +from importlib.machinery import FrozenImporter import itertools import os import re @@ -250,6 +251,8 @@ def filename(self): # Get the filename using loader.get_filename(). Note that this does # more than just loader.filename: for example, it adds /__init__.py # for packages. + if not hasattr(loader, 'get_filename'): + return None filename = loader.get_filename() if not filename: return None