Skip to content

Commit 8fb5878

Browse files
gh-104522: Fix test_subprocess failure when build Python in the root home directory
EPERM is raised when setreuid() fails. EACCES is set in execve() when the test user has not access to sys.executable.
1 parent 6f4b242 commit 8fb5878

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/test/test_subprocess.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -2018,11 +2018,10 @@ def test_user(self):
20182018
user=user,
20192019
close_fds=close_fds)
20202020
except PermissionError as e: # (EACCES, EPERM)
2021-
self.assertIsNone(e.filename)
2022-
except OSError as e:
2023-
if e.errno not in (errno.EACCES, errno.EPERM):
2024-
raise
2025-
self.assertIsNone(e.filename)
2021+
if e.errno == errno.EACCES:
2022+
self.assertEqual(e.filename, sys.executable)
2023+
else:
2024+
self.assertIsNone(e.filename)
20262025
else:
20272026
if isinstance(user, str):
20282027
user_uid = pwd.getpwnam(user).pw_uid

0 commit comments

Comments
 (0)