mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] gh-104522: Fix OSError raised when run a subprocess (GH-114195) (GH-114243)
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 e2c097ebde
)
Co-authored-by: Robert O'Shea <PurityLake@users.noreply.github.com>
This commit is contained in:
parent
9887b0c396
commit
2c9872428e
4 changed files with 28 additions and 17 deletions
|
@ -2030,11 +2030,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
|
||||
|
@ -2078,8 +2079,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
|
||||
|
@ -2124,6 +2125,7 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
except OSError as ex:
|
||||
if ex.errno != errno.EPERM:
|
||||
raise
|
||||
self.assertIsNone(ex.filename)
|
||||
perm_error = True
|
||||
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue