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

Do not call python directly but use sys.executable. Fixes #5872 #5873

Merged
merged 1 commit into from Sep 23, 2019
Merged

Do not call python directly but use sys.executable. Fixes #5872 #5873

merged 1 commit into from Sep 23, 2019

Conversation

scarabeusiv
Copy link
Contributor

@scarabeusiv scarabeusiv commented Sep 23, 2019

Fixes #5872.

@blueyed
Copy link
Contributor

blueyed commented Sep 23, 2019

Thanks!

Just for reference: it is best to use branches for PRs.
Apart from that it would be nice to have a better commit message - it could eg mention the test name etc, and should not be too long.

Normally not really a problem, when it could be squash-merged, but this is disabled here (#4361).

Use sys.executable to detect which python we should actually be testing.
@nicoddemus nicoddemus merged commit 7c64d5d into pytest-dev:master Sep 23, 2019
fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" python -m pytest 8>&1 9>&2')
fp.write(
'COMP_WORDBREAKS="$COMP_WORDBREAKS" {} -m pytest 8>&1 9>&2'.format(
sys.executable
Copy link
Member

Choose a reason for hiding this comment

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

should ~probably be shlex.quote(sys.executable) since we're sticking it into a shell script

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's true. Could you open a PR with that change Anthony?

Copy link
Member

Choose a reason for hiding this comment

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

yep!

Copy link
Contributor

Choose a reason for hiding this comment

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

{!r} might be enough though.

Copy link
Member

Choose a reason for hiding this comment

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

repr is not a substitute for proper shell quoting, that's asking for shell injection ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure.. but this is something we have control over here more or less.
It's good to use the proper way though, of course.. :)

Copy link
Member

Choose a reason for hiding this comment

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

we don't control this at all though, it's a user's directory -- they could do all sorts of wild things with the directory they clone/install pytest into

Copy link
Contributor

Choose a reason for hiding this comment

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

I've meant the user / test runner - who is setting/using sys.executable.

Copy link
Member

Choose a reason for hiding this comment

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

of course, that doesn't stop people from having spaces in their development dirs, or non-ascii usernames, or having quotes in their names

Copy link
Contributor

Choose a reason for hiding this comment

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

Spaces would be handled by the repr() then.
Anyway, your fix is better.

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.

test_argcomplete should not call python directly
4 participants