From bd221c01ddcd2cad102133611fab3569a99680b0 Mon Sep 17 00:00:00 2001 From: Anh71me Date: Mon, 7 Nov 2022 06:13:40 +0800 Subject: gh-98139: enhance namespace package repr --- Lib/importlib/_bootstrap.py | 2 +- Lib/test/test_importlib/test_namespace_pkgs.py | 4 ++++ .../NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-10-30-15-26-33.gh-issue-98139.qtm-9T.rst diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index e0110e7..1a1d5cf 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 f451f75..65428c3 100644 --- a/Lib/test/test_importlib/test_namespace_pkgs.py +++ b/Lib/test/test_importlib/test_namespace_pkgs.py @@ -79,6 +79,10 @@ class SingleNamespacePackage(NamespacePackageTest): with self.assertRaises(ImportError): import foo.two + def test_simple_repr(self): + import foo.one + assert repr(foo).startswith("`. -- cgit v0.12