Skip to content

Commit d3ec82a

Browse files
committed
fix the error message
1 parent 9e98cfc commit d3ec82a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/importlib/resources/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def from_package(package: types.ModuleType):
115115

116116
if package.__spec__ is None:
117117
raise TypeError(
118-
f"Cannot access resources for '{package.__name__}' "
119-
"as it does not correspond to an importable module."
118+
f"Cannot access resources for '{package.__name__ or package!r}' "
119+
"as it does not appear to correspond to an importable module (its __spec__ is None)."
120120
)
121121

122122
spec = wrap_spec(package.__spec__)

Lib/test/test_importlib/resources/test_resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_main_module_with_none_spec(self):
241241

242242
self.assertIsNone(mainmodule.__spec__)
243243

244-
with self.assertRaises(TypeError):
244+
with self.assertRaises(TypeError, msg="Cannot access resources for '__main__' as it does not appear to correspond to an importable module (its __spec__ is None)."):
245245
resources.files(mainmodule)
246246

247247

0 commit comments

Comments
 (0)