GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-35537: subprocess can now use os.posix_spawnp by vstinner · Pull Request #11579 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jan 16, 2019 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The subprocess module can now use the os.posix_spawnp() function if
it is available to locate the program in the PATH.

https://bugs.python.org/issue35537

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
bpo-35537: subprocess can now use os.posix_spawnp
e120153
The subprocess module can now use the os.posix_spawnp() function if
it is available to locate the program in the PATH.
@vstinner vstinner added the skip news label Jan 16, 2019
@vstinner
vstinner requested a review from gpshead as a code owner January 16, 2019 14:07
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jan 16, 2019
@bedevere-bot bedevere-bot added the awaiting merge label Jan 16, 2019
@vstinner
vstinner merged commit 0785889 into python:master Jan 16, 2019
@bedevere-bot bedevere-bot removed the awaiting merge label Jan 16, 2019
@vstinner
vstinner deleted the subprocess_spawnp branch January 16, 2019 14:26
@vstinner vstinner mentioned this pull request Jan 16, 2019
bpo-35537: subprocess can use posix_spawn with pipes #11575
Merged
izbyshev
izbyshev reviewed Jan 16, 2019
View reviewed changes
Comment thread Lib/subprocess.py

self.pid = os.posix_spawn(executable, args, env, **kwargs)
if _HAVE_POSIX_SPAWNP:
self.pid = os.posix_spawnp(executable, args, env, **kwargs)

@izbyshev izbyshev Jan 16, 2019

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please keep in mind that _posixsubprocess is likely to use a different algorithm for searching in PATH compared to posix_spawnp implementations (and, moreover, posix_spawnp implementations differ between libcs and even between versions of the same libc). For example, musl uses execvpe as a "backend" for posix_spawnp, which skips only 3 kinds of errors, while _posixsubprocess skips all errors. Also, EACCES is treated in a special way by both glibc and musl.

Also, the default PATH if the environment variable is not set is likely to differ (e.g., glibc uses /bin:/usr/bin, musl uses /usr/local/bin:/bin:/usr/bin, and Python uses :/bin:/usr/bin).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Jan 16, 2019

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

"... glibc uses /bin:/usr/bin ... and Python uses :/bin:/usr/bin"

Oh. ":" at the start of posixpath.defpath is surprising. Is it a bug? What's the point of putting an empty string in the list of default search paths? It doesn't help to locate an executable...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@izbyshev izbyshev Jan 16, 2019

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It's not a bug: empty entries in PATH mean "the current directory". See also NOTES in man execvp about glibc dropping this empty entry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Jan 16, 2019

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I created https://bugs.python.org/issue35755 to propose to remove it :-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner mentioned this pull request Jan 16, 2019
Revert "bpo-35537: subprocess can now use os.posix_spawnp (GH-11579)" #11582
Merged
@vstinner

vstinner commented Jan 16, 2019

Copy link
Copy Markdown
Member Author

I'm not sure that the exact list of errors catched or nor by subprocess when locating the executable is a major blocker issue, but I didn't notice that subprocess build a list of executable using the PATH computed from its env argument. Using the env argument is a major difference. The devil is in the details...

I'm no longer sure that using posix_spawnp() in subprocess is appropriate. In case of doubt, I prefer to revert this change to have more time to decide what is the best option. I wrote PR #11582 to revert this change.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added a commit that referenced this pull request Jan 16, 2019
@vstinner
Revert "bpo-35537: subprocess can now use os.posix_spawnp (GH-11579)" (…
8c34956
…GH-11582)

This reverts commit 0785889.
@izbyshev izbyshev mentioned this pull request Feb 18, 2019
bpo-35537: Change subprocess to use posix_spawnp instead of posix_spawn #11917
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead Awaiting requested review from gpshead
1 more reviewer
@izbyshev izbyshev izbyshev left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @izbyshev @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.