https://github.com/python/cpython/commit/311d1e2701037952eaf75f993be76f3092c1f01c
commit: 311d1e2701037952eaf75f993be76f3092c1f01c
branch: main
author: Serhiy Storchaka <[email protected]>
committer: encukou <[email protected]>
date: 2024-01-18T10:52:59Z
summary:

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.

files:
M Lib/test/test_subprocess.py

diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 12b88294a2d370..c44a778d5bbefe 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1991,9 +1991,9 @@ def test_process_group_0(self):
 
     @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]
@@ -2018,11 +2018,10 @@ def test_user(self):
                                 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

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to