python / python/cpython

Redundant quotes in `subprocess.TimeoutExpired` message

Offen
#152,558 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib topic-subprocess type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne bei subprocess.TimeoutExpired.str und untersuche die vorhandenen subprocess-Ausnahmetests. Reproduziere das Timeout-Beispiel, passe die erwartete Meldung so an, dass die Befehlsdarstellung nicht redundant eingeschlossen wird, und überprüfe, dass die relevanten subprocess-Tests bestehen; der verknüpfte PR gh-152559 zeigt an, dass die Arbeit bereits im Gange ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
operating-systems
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.