mirror of https://github.com/python/cpython.git
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.
This commit is contained in:
parent
ba683c22ec
commit
311d1e2701
|
@ -1991,9 +1991,9 @@ def test_process_group_0(self):
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(os, 'setreuid'), 'no setreuid on platform')
|
@unittest.skipUnless(hasattr(os, 'setreuid'), 'no setreuid on platform')
|
||||||
def test_user(self):
|
def test_user(self):
|
||||||
# For code coverage of the user parameter. We don't care if we get an
|
# For code coverage of the user parameter. We don't care if we get a
|
||||||
# EPERM error from it depending on the test execution environment, that
|
# permission error from it depending on the test execution environment,
|
||||||
# still indicates that it was called.
|
# that still indicates that it was called.
|
||||||
|
|
||||||
uid = os.geteuid()
|
uid = os.geteuid()
|
||||||
test_users = [65534 if uid != 65534 else 65533, uid]
|
test_users = [65534 if uid != 65534 else 65533, uid]
|
||||||
|
@ -2018,10 +2018,9 @@ def test_user(self):
|
||||||
user=user,
|
user=user,
|
||||||
close_fds=close_fds)
|
close_fds=close_fds)
|
||||||
except PermissionError as e: # (EACCES, EPERM)
|
except PermissionError as e: # (EACCES, EPERM)
|
||||||
self.assertIsNone(e.filename)
|
if e.errno == errno.EACCES:
|
||||||
except OSError as e:
|
self.assertEqual(e.filename, sys.executable)
|
||||||
if e.errno not in (errno.EACCES, errno.EPERM):
|
else:
|
||||||
raise
|
|
||||||
self.assertIsNone(e.filename)
|
self.assertIsNone(e.filename)
|
||||||
else:
|
else:
|
||||||
if isinstance(user, str):
|
if isinstance(user, str):
|
||||||
|
|
Loading…
Reference in New Issue