From: Anh71me Date: Sun, 6 Nov 2022 22:13:40 +0000 (+0800) Subject: gh-98139: enhance namespace package repr X-Git-Tag: v3.12.0a2~101 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd221c01ddcd2cad102133611fab3569a99680b0;p=thirdparty%2FPython%2Fcpython.git gh-98139: enhance namespace package repr --- diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index e0110e701d6c..1a1d5cf7c9c3 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 f451f7547b35..65428c3d3ead 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("`.