Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-35674: Expose posix_spawnp #11554

Merged
merged 3 commits into from
Jan 16, 2019
Merged

bpo-35674: Expose posix_spawnp #11554

merged 3 commits into from
Jan 16, 2019

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Jan 14, 2019

I have exposed posix_spawnp.

Co-Author: Victor Stinner vstinner@redhat.com

https://bugs.python.org/issue35674

Doc/library/os.rst Outdated Show resolved Hide resolved
Doc/library/os.rst Show resolved Hide resolved
Lib/test/test_posix.py Outdated Show resolved Hide resolved
Lib/test/test_posix.py Outdated Show resolved Hide resolved
if pid2 != pid:
raise Exception(f"pid {pid2} != {pid}")
if status != 0:
raise Exception(f"status = {status}")
Copy link
Member

Choose a reason for hiding this comment

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

maybe write: f"status {status} != 0"

Modules/posixmodule.c Outdated Show resolved Hide resolved
@@ -5489,8 +5461,15 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
attrp = &attr;

_Py_BEGIN_SUPPRESS_IPH
err_code = posix_spawn(&pid, path->narrow,
if (whichspawn == 0){
Copy link
Member

Choose a reason for hiding this comment

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

Since I suggest use_posix_spawnp, I also suggest:

if (use_posix_spawnp) {
   ... posix_spawnp ...
}
else {
   ... posix_spawn ...
}

[clinic start generated code]*/


#ifdef HAVE_POSIX_SPAWNP
Copy link
Member

Choose a reason for hiding this comment

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

The #ifdef must be outside [clinic start generated code].

I propose to reuse the existring #ifdef HAVE_POSIX_SPAWN, so don't add a new #ifdef HAVE_POSIX_SPAWN but just move the closing #endif /* HAVE_POSIX_SPAWN */ to include your new code.

Note: Currently, "make clinic" fails. Make sure that "make clinic" works as expected.

I bet that posix_spawnp() is always available when posix_spawn() is available. If it's not the case, we can fix that later.

@vstinner
Copy link
Member

AppVeyor build failed

That's because of the #ifdef issue, see my comment.

PyObject *env, PyObject *file_actions,
PyObject *setpgroup, int resetids, PyObject *setsigmask,
PyObject *setsigdef, PyObject *scheduler)
PyObject *setsigdef, PyObject *scheduler, int which)
/*[clinic end generated code: output=45dfa4c515d09f2c input=2891c2f1d457e39b]*/
Copy link
Member

Choose a reason for hiding this comment

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

I think this line needs to be deleted to avoid confusing the argument clinic

Modules/posixmodule.c Outdated Show resolved Hide resolved
@pablogsal
Copy link
Member

Very good job Joannah! :)

I left some comments together with Victor's review. Ping me when you have addressed them.

Modules/posixmodule.c Outdated Show resolved Hide resolved
Modules/posixmodule.c Outdated Show resolved Hide resolved
Doc/library/os.rst Show resolved Hide resolved
Lib/test/test_posix.py Show resolved Hide resolved
@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@@ -0,0 +1,2 @@
:func:os.posix_spawnp
Copy link
Member

Choose a reason for hiding this comment

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

Hum, you need to write a sentence. Something like:

Suggested change
:func:os.posix_spawnp
Add a new :func:`os.posix_spawnp` function. Patch by Joannah Nanjekye.

Modules/posixmodule.c Outdated Show resolved Hide resolved
Modules/posixmodule.c Show resolved Hide resolved
Modules/posixmodule.c Show resolved Hide resolved
Modules/posixmodule.c Show resolved Hide resolved
Modules/posixmodule.c Outdated Show resolved Hide resolved
* Fix also indentation in posixmodule.c.
* Remove "if the *path* argument contains no directory" from
  os.posix_spawnp() doc
* Remove outdated comment from py_posix_spawn():
  /*[clinic end generated code: ...]*/
@vstinner vstinner dismissed serhiy-storchaka’s stale review January 16, 2019 13:19

Serhiy's comments have been addressed.

@vstinner
Copy link
Member

I checked Travis CI jobs. posix_spawnp is available on Linux and macOS jobs, but glibc is too old on the Linux for subprocess.

Linux:

# configure
checking for posix_spawn... yes
checking for posix_spawnp... yes

# pythoninfo
platform.libc_ver: glibc 2.19
subprocess._USE_POSIX_SPAWN: False

macOS:

# configure
checking for posix_spawn... yes
checking for posix_spawnp... yes

# pythoninfo
platform.platform: macOS-10.13.3-x86_64-i386-64bit
subprocess._USE_POSIX_SPAWN: True

@vstinner vstinner merged commit 92b8322 into python:master Jan 16, 2019
@vstinner
Copy link
Member

Well done @nanjekyejoannah :-) Thanks to Joannah for this nice enhancement and to all reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants