Skip to content

Commit

Permalink
Fix for #281
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Carreau committed Jan 23, 2024
1 parent 5d06d73 commit 5bb363e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/python/pyflyby/_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import ast
from functools import total_ordering
from importlib.machinery import FrozenImporter
import itertools
import os
import re
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5bb363e

Please sign in to comment.