diff --git a/Lib/posixpath.py b/Lib/posixpath.py index fccca4e066b76f1..10dda744d4d4dba 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -266,6 +266,7 @@ def expanduser(path): name = os.fsdecode(name) try: pwent = pwd.getpwnam(name) + print(f"expanduser: {pwent=!r}") except KeyError: # bpo-10496: if the user name from the path doesn't exist in the # password database, return the path unchanged diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 9f36a4cd9ce43f7..5e69d68b0f527e7 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -361,9 +361,11 @@ def test_expanduser_pwd2(self): pwd = import_helper.import_module('pwd') for entry in pwd.getpwall(): name = entry.pw_name + entry2 = pwd.getpwnam(name) + home = entry.pw_dir home = home.rstrip('/') or '/' - with self.subTest(pwd=entry): + with self.subTest(pwd=entry, entry2=entry2): self.assertEqual(posixpath.expanduser('~' + name), home) self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)), os.fsencode(home))