gh-151485: Fix command quoting in subprocess.CalledProcessError.__str__#151486
Conversation
CalledProcessError previously formatted cmd as `"... '%s' ..."`. This lead to unbalanced quoting when cmd contains single-quotes or, more commonly, when cmd is a list. This change updates the relevant format strings to use %r instead.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
vstinner
left a comment
There was a problem hiding this comment.
Can you please add a test to test_subprocess?
Ah, the job was cancelled, test_abc seems to be stuck: |
I created #151593 to investigate this test_abc issue. |
|
Merged, thanks for the fix. I don't think that it should be backported since it can impact tests relying on the exact |
|
Thanks! Out of curiosity, what's the policy for fixes like these when it comes to beta releases? |
After the feature freeze (beta1), new features and backward incompatible changes are no longer accepted (in the 3.15 branch). |
subprocess.CalledProcessError.__str__previously formattedcmdas"... '%s' ...". This lead to unbalanced quoting when cmd contains single-quotes or, more commonly, whencmdis a list. This change updates the relevant format strings to use%rinstead.In terms of backwards compatibility, the only impact I anticipate is on doctests, and I suspect doctests for
subprocess.CalledProcessErrorto be quite rare.Before this PR:
After: