Skip to content

gh-104522: Fix OSError raised when run a subprocess#114195

Merged
gpshead merged 1 commit into
python:mainfrom
serhiy-storchaka:subprocess-error-filename
Jan 18, 2024
Merged

gh-104522: Fix OSError raised when run a subprocess#114195
gpshead merged 1 commit into
python:mainfrom
serhiy-storchaka:subprocess-error-filename

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jan 17, 2024

Copy link
Copy Markdown
Member

Only set filename to cwd if it was caused by failed chdir(cwd).

_fork_exec() now returns "noexec:chdir" for failed chdir(cwd).

Based on idea from #104851. It is more reliable, because does not guess, but know if the error was caused by chdir(cwd). It also contains tests.

Only set filename to cwd if it was caused by failed chdir(cwd).

_fork_exec() now returns "noexec:chdir" for failed chdir(cwd).

Co-authored-by: Robert O'Shea <PurityLake@users.noreply.github.com>

@gpshead gpshead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice user experience improvement bugfix!

@gpshead gpshead added needs backport to 3.12 only security fixes needs backport to 3.11 only security fixes type-bug An unexpected behavior, bug, or error labels Jan 18, 2024
@gpshead gpshead merged commit e2c097e into python:main Jan 18, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka and @gpshead, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e2c097ebdee447ded1109f99a235e65aa3533bf8 3.11

@bedevere-app

bedevere-app Bot commented Jan 18, 2024

Copy link
Copy Markdown

GH-114219 is a backport of this pull request to the 3.12 branch.

@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Debian root 3.12 has failed when building commit f8fc853.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1102/builds/605) and take a look at the build logs.
  4. Check if the failure is related to this commit (f8fc853) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1102/builds/605

Failed tests:

  • test_subprocess

Failed subtests:

  • test_user - test.test_subprocess.POSIXProcessTestCase.test_user

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/test/test_subprocess.py", line 2030, in test_user
    output = subprocess.check_output(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/subprocess.py", line 1953, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/root/buildarea/3.12.angelico-debian-amd64/build/python'


Traceback (most recent call last):
  File "/root/buildarea/3.12.angelico-debian-amd64/build/Lib/test/test_subprocess.py", line 2036, in test_user
    self.assertIsNone(e.filename)
AssertionError: '/root/buildarea/3.12.angelico-debian-amd64/build/python' is not None

@bedevere-app

bedevere-app Bot commented Jan 18, 2024

Copy link
Copy Markdown

GH-114243 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Jan 18, 2024
@serhiy-storchaka serhiy-storchaka deleted the subprocess-error-filename branch July 1, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants