Redundant quotes in `subprocess.TimeoutExpired` message
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
Bug description:
While looking into https://github.com/python/cpython/pull/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
- gh-152559
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at subprocess.TimeoutExpired.str and inspect the existing subprocess exception tests. Reproduce the timeout example, adjust the expected message so the command representation is not redundantly wrapped, and verify the relevant subprocess tests pass; linked PR gh-152559 indicates work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100