Bug report
Bug description:
Bug description:
While looking into #151486, I noticed a similar issue in subprocess.TimeoutExpired.__str__.
subprocess.TimeoutExpired.__str__ manually wraps cmd in single quotes while formatting the exception message.
This produces confusing output when cmd is a list, because the list representation already contains quotes around its string elements.
import subprocess
import sys
cmd = [sys.executable, "-c", "import time; time.sleep(10)"]
subprocess.run(cmd, timeout=0.01)
Current output:
Traceback (most recent call last):
...
subprocess.TimeoutExpired: Command '['...python...', '-c', 'import time; time.sleep(10)']' timed out after 0.01 seconds
Expected output:
Traceback (most recent call last):
...
subprocess.TimeoutExpired: Command ['...python...', '-c', 'import time; time.sleep(10)'] timed out after 0.01 seconds
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
Bug description:
While looking into #151486, I noticed a similar issue in
subprocess.TimeoutExpired.__str__.subprocess.TimeoutExpired.__str__manually wrapscmdin single quotes while formatting the exception message.This produces confusing output when
cmdis a list, because the list representation already contains quotes around its string elements.Current output:
Expected output:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
subprocess.TimeoutExpired.__str__#152559