Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/importlib/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def __init__(self, path):
self._path = path

def read_text(self, filename):
with suppress(FileNotFoundError, NotADirectoryError, KeyError):
with suppress(FileNotFoundError, IsADirectoryError, KeyError,
NotADirectoryError, PermissionError):
return self._path.joinpath(filename).read_text(encoding='utf-8')
read_text.__doc__ = Distribution.read_text.__doc__

Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_importlib/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,11 @@ def test_package_discovery(self):
dist.metadata['Name'] == 'distinfo-pkg'
for dist in dists
)


class DirectoryTest(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
def test(self):
# make an `EGG-INFO` directory that's unrelated
self.site_dir.joinpath('EGG-INFO').mkdir()
# used to crash with `IsADirectoryError`
self.assertIsNone(version('unknown-package'))