Skip to content

Redundant quotes in subprocess.TimeoutExpired message #152558

Description

@lpyu001

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-subprocessSubprocess issues.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions