Skip to content

Commit bad45d5

Browse files
committed
Suppress all TraversalErrors in MultiplexedPath. Fixes #253.
1 parent bbec3af commit bad45d5

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

importlib_resources/readers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,10 @@ def is_file(self):
8585
def joinpath(self, *descendants):
8686
try:
8787
return super().joinpath(*descendants)
88-
except abc.TraversalError as exc:
89-
# One of the paths didn't resolve.
90-
msg, target, names = exc.args
91-
if names: # pragma: nocover
92-
raise
93-
# It was the last; construct result with the first path.
94-
return self._paths[0].joinpath(target)
88+
except abc.TraversalError:
89+
# One of the paths did not resolve (a directory does not exist).
90+
# Just return something that will not exist.
91+
return self._paths[0].joinpath(*descendants)
9592

9693
def open(self, *args, **kwargs):
9794
raise FileNotFoundError(f'{self} is not a file')

importlib_resources/tests/test_reader.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import pathlib
44
import unittest
55

6-
import pytest
7-
86
from importlib import import_module
97
from importlib_resources.readers import MultiplexedPath, NamespaceReader
108

@@ -79,7 +77,6 @@ def test_join_path(self):
7977
)
8078
self.assertEqual(path.joinpath(), path)
8179

82-
@pytest.mark.xfail(reason="#253")
8380
def test_join_path_compound(self):
8481
path = MultiplexedPath(self.folder)
8582
assert not path.joinpath('imaginary/foo.py').exists()

0 commit comments

Comments
 (0)