Skip to content

Commit 311d1e2

Browse files
gh-104522: Fix test_subprocess failure when build Python in the root home directory (GH-114236)
* 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 ba683c2 commit 311d1e2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Lib/test/test_subprocess.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1991,9 +1991,9 @@ def test_process_group_0(self):
19911991

19921992
@unittest.skipUnless(hasattr(os, 'setreuid'), 'no setreuid on platform')
19931993
def test_user(self):
1994-
# For code coverage of the user parameter. We don't care if we get an
1995-
# EPERM error from it depending on the test execution environment, that
1996-
# still indicates that it was called.
1994+
# For code coverage of the user parameter. We don't care if we get a
1995+
# permission error from it depending on the test execution environment,
1996+
# that still indicates that it was called.
19971997

19981998
uid = os.geteuid()
19991999
test_users = [65534 if uid != 65534 else 65533, uid]
@@ -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)