diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-01-18 12:18:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 12:18:15 (GMT) |
commit | eb582df61fcdbdd5b510da5d3744e5f60bf8b81d (patch) | |
tree | c38ad589531fdd0a0dcd3129e790c42c28341c1b | |
parent | 55b73a5c78209cda7bafd0aa472b2ab89068b7ef (diff) | |
download | cpython-eb582df61fcdbdd5b510da5d3744e5f60bf8b81d.zip cpython-eb582df61fcdbdd5b510da5d3744e5f60bf8b81d.tar.gz cpython-eb582df61fcdbdd5b510da5d3744e5f60bf8b81d.tar.bz2 |
[3.12] gh-104522: Fix test_subprocess failure when build Python in the root home directory (GH-114236) (GH-114239)
EPERM is raised when setreuid() fails.
EACCES is set in execve() when the test user has not access to sys.executable.
(cherry picked from commit 311d1e2701037952eaf75f993be76f3092c1f01c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r-- | Lib/test/test_subprocess.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 5f94a40..b2ebfbe 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -2006,9 +2006,9 @@ class POSIXProcessTestCase(BaseTestCase): @unittest.skipUnless(hasattr(os, 'setreuid'), 'no setreuid on platform') def test_user(self): - # For code coverage of the user parameter. We don't care if we get an - # EPERM error from it depending on the test execution environment, that - # still indicates that it was called. + # For code coverage of the user parameter. We don't care if we get a + # permission error from it depending on the test execution environment, + # that still indicates that it was called. uid = os.geteuid() test_users = [65534 if uid != 65534 else 65533, uid] @@ -2033,11 +2033,10 @@ class POSIXProcessTestCase(BaseTestCase): user=user, close_fds=close_fds) except PermissionError as e: # (EACCES, EPERM) - self.assertIsNone(e.filename) - except OSError as e: - if e.errno not in (errno.EACCES, errno.EPERM): - raise - self.assertIsNone(e.filename) + if e.errno == errno.EACCES: + self.assertEqual(e.filename, sys.executable) + else: + self.assertIsNone(e.filename) else: if isinstance(user, str): user_uid = pwd.getpwnam(user).pw_uid |