From 6a55404968b2da12124b9dc5164db1f5354b9012 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 23 Jan 2024 09:50:36 +0100 Subject: [PATCH] Fix for #281 It seem that in 3.11 there is now another FrozenImporter from _frozen_importlib, I did not manage to get isinstance to work with it so we need to check with hasattr. --- lib/python/pyflyby/_modules.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/python/pyflyby/_modules.py b/lib/python/pyflyby/_modules.py index fb37cdc4..add41481 100644 --- a/lib/python/pyflyby/_modules.py +++ b/lib/python/pyflyby/_modules.py @@ -250,6 +250,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