Skip to content

Commit 7146a45

Browse files
committed
Fix test failure on Python 2.7
1 parent 8192c06 commit 7146a45

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

importlib_resources/_compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
from pathlib2 import Path, PurePath # type: ignore
99

1010

11+
try:
12+
from contextlib import suppress
13+
except ImportError:
14+
from contextlib2 import suppress # type: ignore
15+
16+
1117
try:
1218
from functools import singledispatch
1319
except ImportError:

importlib_resources/trees.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ._compat import (
88
Path, package_spec, FileNotFoundError, ZipPath,
9-
singledispatch,
9+
singledispatch, suppress,
1010
)
1111

1212

@@ -24,7 +24,7 @@ def from_traversable_resources(spec):
2424
If the spec.loader implements TraversableResources,
2525
directly or implicitly, it will have a ``files()`` method.
2626
"""
27-
with contextlib.suppress(AttributeError):
27+
with suppress(AttributeError):
2828
return spec.loader.files()
2929

3030

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ install_requires =
2222
zipp >= 0.4; python_version < '3.8'
2323
singledispatch; python_version < '3.4'
2424
importlib_metadata; python_version < '3.8'
25+
contextlib2; python_version < '3'
2526
setup_requires = setuptools_scm[toml] >= 3.4.1
2627
packages = find:
2728

0 commit comments

Comments
 (0)