From a49c917bb49e2227ffa865980e13be38c7986608 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 23 Jan 2024 09:50:36 +0100 Subject: [PATCH] Blind fix for #281 I don't understand why the bug is happening, and why this get a FrozenImporter as it was never getting one before, but this should fix the bug. --- lib/python/pyflyby/_modules.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/python/pyflyby/_modules.py b/lib/python/pyflyby/_modules.py index fb37cdc4..40dcdc76 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,9 @@ 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 isinstance(loader, FrozenImporter): + assert not hasattr(loader, 'get_filename') + return None filename = loader.get_filename() if not filename: return None