diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 41c42299195..f7621a0674c 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -167,6 +167,14 @@ class HelperFunctionsTests(unittest.TestCase): if isinstance(path, str): self.assertNotIn("abc\x00def", path) + def test_pth_exc_namespacing(self): + # Issue 38937 + contents = "import sys; x = 5; [print(x + i) for i in range(5)]\n" + pth_dir, pth_fn = self.make_pth(contents) + with captured_stderr() as err_out: + self.assertFalse(site.addpackage(pth_dir, pth_fn, set())) + self.assertEqual(err_out.getvalue(), "") + def test_addsitedir(self): # Same tests for test_addpackage since addsitedir() essentially just # calls addpackage() for every .pth file in the directory