Skip to content

Commit

Permalink
Use LBYL
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed Oct 31, 2017
1 parent eaeae38 commit fc2337d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions importlib_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def open(package: Package, file_name: FileName) -> BinaryIO:
"""Return a file-like object opened for binary-reading of the resource."""
file_name = _normalize_path(file_name)
package = _get_package(package)
try:
if hasattr(package.__spec__.loader, 'open_resource'):
return package.__spec__.loader.open_resource(file_name)
except AttributeError:
else:
# Using pathlib doesn't work well here due to the lack of 'strict'
# argument for pathlib.Path.resolve() prior to Python 3.6.
absolute_package_path = os.path.abspath(package.__spec__.origin)
Expand Down

0 comments on commit fc2337d

Please sign in to comment.