Skip to content

Commit 4dedeeb

Browse files
committed
Modify the error message
1 parent 847d8df commit 4dedeeb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/importlib/resources/_common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def from_package(package: types.ModuleType):
114114
from ._adapters import wrap_spec
115115

116116
if package.__spec__ is None:
117-
raise TypeError(f"Can't access resources on a module with no spec: {package}")
117+
raise TypeError(
118+
f"Cannot access resources because the code used to populate the {package.__name__} "
119+
"does not correspond directly with an importable module."
120+
)
118121

119122
spec = wrap_spec(package.__spec__)
120123
reader = spec.loader.get_resource_reader(spec.name)

0 commit comments

Comments
 (0)