From 64d592bfa3fb0a163edc88064618122a1d9af87d Mon Sep 17 00:00:00 2001 From: iyume Date: Sun, 30 Oct 2022 14:52:23 +0800 Subject: [PATCH 1/2] fix namespace repr; test simple repr --- Lib/importlib/_bootstrap.py | 2 +- Lib/test/test_importlib/test_namespace_pkgs.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index e0110e701d6cde..1a1d5cf7c9c33e 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -580,7 +580,7 @@ def _module_repr_from_spec(spec): if spec.loader is None: return f'' else: - return f'' + return f'' else: if spec.has_location: return f'' diff --git a/Lib/test/test_importlib/test_namespace_pkgs.py b/Lib/test/test_importlib/test_namespace_pkgs.py index f451f7547b35bb..65428c3d3ead9b 100644 --- a/Lib/test/test_importlib/test_namespace_pkgs.py +++ b/Lib/test/test_importlib/test_namespace_pkgs.py @@ -79,6 +79,10 @@ def test_cant_import_other(self): with self.assertRaises(ImportError): import foo.two + def test_simple_repr(self): + import foo.one + assert repr(foo).startswith(" Date: Sun, 30 Oct 2022 15:27:24 +0800 Subject: [PATCH 2/2] add NEWS because web tools 500 --- .../next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst diff --git a/Misc/NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst b/Misc/NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst new file mode 100644 index 00000000000000..ed5dd003062760 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst @@ -0,0 +1,2 @@ +In :mod:`importlib._bootstrap`, enhance namespace package repr to ``.