summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-01-18 01:19:11 (GMT)
committerGitHub <noreply@github.com>2024-01-18 01:19:11 (GMT)
commitf8fc8534c4abd384160b3b03a253bb0a30e6ba68 (patch)
treea9c30890e7b6c2bfcebd932863700a002b12e7a0 /Lib/test
parent2c9cf64a3fa2b476c66eb80970e02933b7d33d05 (diff)
downloadcpython-f8fc8534c4abd384160b3b03a253bb0a30e6ba68.zip
cpython-f8fc8534c4abd384160b3b03a253bb0a30e6ba68.tar.gz
cpython-f8fc8534c4abd384160b3b03a253bb0a30e6ba68.tar.bz2
[3.12] gh-104522: Fix OSError raised when run a subprocess (GH-114195) (#114219)
gh-104522: Fix OSError raised when run a subprocess (GH-114195) Only set filename to cwd if it was caused by failed chdir(cwd). _fork_exec() now returns "noexec:chdir" for failed chdir(cwd). (cherry picked from commit e2c097ebdee447ded1109f99a235e65aa3533bf8) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Robert O'Shea <PurityLake@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_subprocess.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 9ade90f..5f94a40 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2032,11 +2032,12 @@ class POSIXProcessTestCase(BaseTestCase):
"import os; print(os.getuid())"],
user=user,
close_fds=close_fds)
- except PermissionError: # (EACCES, EPERM)
- pass
+ 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)
else:
if isinstance(user, str):
user_uid = pwd.getpwnam(user).pw_uid
@@ -2080,8 +2081,8 @@ class POSIXProcessTestCase(BaseTestCase):
"import os; print(os.getgid())"],
group=group,
close_fds=close_fds)
- except PermissionError: # (EACCES, EPERM)
- pass
+ except PermissionError as e: # (EACCES, EPERM)
+ self.assertIsNone(e.filename)
else:
if isinstance(group, str):
group_gid = grp.getgrnam(group).gr_gid
@@ -2129,7 +2130,8 @@ class POSIXProcessTestCase(BaseTestCase):
[sys.executable, "-c",
"import os, sys, json; json.dump(os.getgroups(), sys.stdout)"],
extra_groups=group_list)
- except PermissionError:
+ except PermissionError as e:
+ self.assertIsNone(e.filename)
self.skipTest("setgroup() EPERM; this test may require root.")
else:
parent_groups = os.getgroups()