WIP: Update process spawning in platforms - #4885
Open
mwichmann wants to merge 1 commit into
Open
Conversation
Default is now simplified functions that just use subprocess.run(). On posix, the escape function is now shlex.quote from stdlib. On win32, some funky dances with temporary files are eliminated, as subprocess is quite capable of capturing output. In Subst, quote_spaces is generalized a bit, and a TODO is left in the comments - it doesn't look like CmdStringHolder.escape ever gets called with a quote_func argument, so the current way is a bit inefficient, but it's unlikely to be a compelling improvement so seems not worth the research to be sure "nothing breaks". The change of escape function on posix means a couple of places in one test see a change: some arguments that don't need quoting are no longer quoted. Specifically, it's these two former expectations: BF: %(_python_)s myfail.py f03 f04 "f04" "f04.in" BF: %(_python_)s myfail.py f04 f05 "f05" "f05.in" It's possible that the former slightly funky posix quoting, was to match the win32 output, so tests like this can work with the same output on both flavors. The test is modified to paste in a platform-specific variable to account for the current difference. Going back to the old quoting style is, in a sense, disjoint from the change to use subprocess. Signed-off-by: Mats Wichmann <mats@linux.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note: this is not ready for inclusion in the currently pending release, it needs more proof. Pushing as a PR so can get a full CI run on it.
Edit: that's why we do these exercises, I guess. On the two Windows github runners that use Python 3.9, three tests fail (the same three), with an odd error:
Exploring the mystery...
Assisted by AI for the win32 platform module, which is complicated by the fact that switching from
spawnv*functions tosubprocessmeans arguments have to be prepared differently;subprocesshas a helper function that runs if an argument vector is passed, except it doesn't help our use case because we've already done some quoting work, and stuff would end up with excess quotes.Default is now simplified functions that just use
subprocess.run(). On posix, the escape function is nowshlex.quotefrom stdlib. On win32, some funky dances with temporary files are eliminated, assubprocessis quite capable of capturing output.In
Subst.py,quote_spacesis generalized a bit, and a TODO is left in the comments - it doesn't look likeCmdStringHolder.escapeever gets called with aquote_funcargument, so the current way is a bit inefficient, but it's unlikely to be a compelling improvement so seems not worth the research to be sure "nothing breaks".The change of escape function on posix means a couple of places in one test see a change: some arguments that don't need quoting are no longer quoted. Specifically, it's these two former expectations:
It's possible that the former slightly funky posix quoting was actually to match the win32 output, so tests like this can work with the same output on both flavors. For now, the test is modified to paste in a platform-specific variable to account for the current difference. Going back to the old quoting style is, in a sense, disjoint from the change to use subprocess.
Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).