On this page
subprocess.SubprocessError
Prev: subprocess.run | Up: subprocess | Next: subprocess.TimeoutExpired
Rel: subprocess.call, subprocess.CalledProcessError, subprocess.check_call, subprocess.check_output
Ref: docs.python.org โ subprocess.SubprocessError
Tags: #public #python3 #stdlib #subprocess
Import
import subprocess
from subprocess import SubprocessError
Signature & Overview
subprocess.SubprocessError(...)
subprocess.SubprocessError class.
Methods & Attributes
SubprocessError.add_note(self, note, /)โ Add a note to the exceptionSubprocessError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import subprocess
import sys
try:
subprocess.run([sys.executable, "-c", "raise SystemExit(1)"], check=True)
except subprocess.SubprocessError as exc:
assert isinstance(exc, subprocess.CalledProcessError)
Gotchas
- Base class for
CalledProcessErrorandTimeoutExpired: Useful when you want oneexceptclause covering both non-zero exit codes and timeouts. - Does NOT catch
FileNotFoundError: A missing executable raisesFileNotFoundError(OSError), notSubprocessError.
REPL Inspect
from subprocess import SubprocessError
help(SubprocessError)
Linked from
Related notes
- tuts/python3/stdlib_module/subprocess/run Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/TimeoutExpired Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/subprocess/call Linked here; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/CalledProcessError Linked here; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/check_call Linked here; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/check_output Linked here; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/CompletedProcess shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/getoutput shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/getstatusoutput shared tags: #stdlib, #subprocess