Skip to content

Commit 2e9a79f

Browse files
committed
Move check for path.is_file to _py2, as it's only encountered there :(
1 parent 2a4b00d commit 2e9a79f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

importlib_resources/_py2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ def path(package, resource):
108108
raised if the file was deleted prior to the context manager
109109
exiting).
110110
"""
111-
return trees.as_file(get(package, resource))
111+
path = get(package, resource)
112+
if not path.is_file():
113+
raise FileNotFoundError(path)
114+
return trees.as_file(path)
112115

113116

114117
def is_resource(package, name):

importlib_resources/trees.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ def as_file(path):
8989
Given a path-like object, return that object as a
9090
path on the local file system in a context manager.
9191
"""
92-
if not path.is_file():
93-
raise FileNotFoundError(path)
9492
# todo: consider using functools.singledispatch
9593
wrapper = (
9694
_zip_path_as_file

0 commit comments

Comments
 (0)