This was broken when script was a list instead of a string. I caught this
with an internal extension at Google, and I'm not really sure why it wasn't
caught in any kind of CI.
Details
- Reviewers
mharbison72 - Group Reviewers
hg-reviewers - Commits
- rHGfdd54a876213: procutil: use rapply(tonativestr, ...) to preserve lists when they come in
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
mercurial/utils/procutil.py | ||
---|---|---|
642–645 | Reading https://docs.python.org/3/library/subprocess.html#popen-constructor, it sounds like it's valid to pass a sequence also when shell=True, so maybe the condition should be if isinstance(script, bytes) or similar instead? |
procutil: correctly convert to bytes when shell=False
nit: we're converting away from bytes (at least on Windows), aren't we?
I'll take a look at this tomorrow. I assume you triggered a crash- is there an easy way to hit this new code? I wonder if the other process-spawning functions have the same issue.
mercurial/utils/procutil.py | ||
---|---|---|
642–645 | I was wondering if the right thing to do is use pycompat.rapply so a list stays a list and a byte string is converted directly. |
@mharbison72 was right on the money with rapply here. Fixes my issue much more elegantly.
Queued for stable, thanks. It looks like none of the other Popen() calls in this module use rapply. IDK why they wouldn't trigger a failure
Reading https://docs.python.org/3/library/subprocess.html#popen-constructor, it sounds like it's valid to pass a sequence also when shell=True, so maybe the condition should be if isinstance(script, bytes) or similar instead?