Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix the error message
  • Loading branch information
whitphx committed Oct 22, 2025
commit d3ec82a71c119e3eda2f2ea81a2af4a734c4785c
4 changes: 2 additions & 2 deletions Lib/importlib/resources/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def from_package(package: types.ModuleType):

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

spec = wrap_spec(package.__spec__)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_importlib/resources/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_main_module_with_none_spec(self):

self.assertIsNone(mainmodule.__spec__)

with self.assertRaises(TypeError):
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)."):
resources.files(mainmodule)


Expand Down
Loading