We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eaeae38 commit fc2337dCopy full SHA for fc2337d
importlib_resources/__init__.py
@@ -47,9 +47,9 @@ def open(package: Package, file_name: FileName) -> BinaryIO:
47
"""Return a file-like object opened for binary-reading of the resource."""
48
file_name = _normalize_path(file_name)
49
package = _get_package(package)
50
- try:
+ if hasattr(package.__spec__.loader, 'open_resource'):
51
return package.__spec__.loader.open_resource(file_name)
52
- except AttributeError:
+ else:
53
# Using pathlib doesn't work well here due to the lack of 'strict'
54
# argument for pathlib.Path.resolve() prior to Python 3.6.
55
absolute_package_path = os.path.abspath(package.__spec__.origin)
0 commit comments