Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-35674: Expose posix_spawnp #11545

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

Closed
wants to merge 1 commit into from
Closed

Conversation

saraharkam
Copy link

@saraharkam saraharkam commented Jan 13, 2019

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Please do the following changes:

  • Your change contains an obvious bug... you have to exchange the true/false blocks of:

    err_code = posix_spawn(&pid, path->narrow,
    if(use_posixspawnp){
                           file_actionsp, attrp, argvlist, envlist);
        err_code = posix_spawn(&pid, path->narrow,
                               file_actionsp, attrp, argvlist, envlist);
    }
    else {
        err_code = posix_spawnp(&pid, path->narrow,
                                file_actionsp, attrp, argvlist, envlist);
    }
  • Include also Modules/clinic/posixmodule.c.h generated change in your PR: run "make "clinic".
  • Replace true/false with 1/0 your posixmodule.c changes: we don't use stdbool.h in CPython code base and true/false caused me compilation error.
  • Add the unit test that I wrote below, add it to TestPosixSpawn of Lib/test/test_posix.py:
     @support.skip_unless_symlink
    def test_posix_spawnp(self):
        # Use a symlink to create a program in its own temporary directory
        temp_dir = tempfile.mkdtemp()
        self.addCleanup(support.rmtree, temp_dir)

        program = 'posix_spawnp_test_program.exe'
        program_fullpath = os.path.join(temp_dir, program)
        os.symlink(sys.executable, program_fullpath)

        path = os.environ.get('PATH', '')
        path = os.pathsep.join((temp_dir, path))
        env = dict(os.environ, PATH=path)

        spawn_args = (program, '-I', '-S', '-c', 'pass')
        code = textwrap.dedent("""
            import os
            args = %a
            env = %a
            pid = os.posix_spawnp(args[0], args, env)
            pid2, status = os.waitpid(pid, 0)
            if pid2 != pid:
                raise Exception(f"pid {pid2} != {pid}")
            if status != 0:
                raise Exception(f"status = {status}")
        """ % (spawn_args, env))

        # Use a subprocess to test os.posix_spawnp() with a modified PATH
        # environment variable: posix_spawnp() uses the current environment
        # to locate the program, not its environment argument.
        args = ('-c', code)
        assert_python_ok(*args, PATH=path)

@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.

@vstinner
Copy link
Member

Hi @saraharkam, @nanjekyejoannah assigned the issue to herself last Thursday (January 10): https://bugs.python.org/issue35674#msg333375

Would you be ok to let Joannah implement the feature?

Note: I'm mentoring Joannah.

@vstinner
Copy link
Member

I don't like to do that, but I close the issue because @nanjekyejoannah assigned the issue to her. She just wrote PR #11554.

@saraharkam: Don't hesitate to propose other PRs, I may have a look and welcome in Python!

@vstinner vstinner closed this Jan 14, 2019
@saraharkam
Copy link
Author

Sorry 😞

I will search another issue that I can contribute.

@saraharkam saraharkam deleted the pspawnp branch January 14, 2019 22:15
@vstinner
Copy link
Member

No need to be sorry. I am sorry of closing your PR. You can follow discussions PR #11554 and maybe help joannah.

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

Successfully merging this pull request may close these issues.

4 participants