mirror of
https://github.com/python/cpython.git
synced 2025-09-19 07:00:59 +00:00
Add a SubprocessError base class for exceptions in the subprocess module.
This commit is contained in:
parent
1c711f0ef9
commit
54d412edcc
2 changed files with 14 additions and 4 deletions
|
@ -387,6 +387,11 @@ All of the functions and methods that accept a *timeout* parameter, such as
|
||||||
:func:`call` and :meth:`Popen.communicate` will raise :exc:`TimeoutExpired` if
|
:func:`call` and :meth:`Popen.communicate` will raise :exc:`TimeoutExpired` if
|
||||||
the timeout expires before the process exits.
|
the timeout expires before the process exits.
|
||||||
|
|
||||||
|
Exceptions defined in this module all inherit from :ext:`SubprocessError`.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
The :exc:`SubprocessError` base class was added.
|
||||||
|
|
||||||
|
|
||||||
Security
|
Security
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
|
@ -191,8 +191,10 @@ should prepare for OSErrors.
|
||||||
|
|
||||||
A ValueError will be raised if Popen is called with invalid arguments.
|
A ValueError will be raised if Popen is called with invalid arguments.
|
||||||
|
|
||||||
check_call() and check_output() will raise CalledProcessError, if the
|
Exceptions defined within this module inherit from SubprocessError.
|
||||||
called process returns a non-zero return code.
|
check_call() and check_output() will raise CalledProcessError if the
|
||||||
|
called process returns a non-zero return code. TimeoutExpired
|
||||||
|
be raised if a timeout was specified and expired.
|
||||||
|
|
||||||
|
|
||||||
Security
|
Security
|
||||||
|
@ -348,7 +350,10 @@ import builtins
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
# Exception classes used by this module.
|
# Exception classes used by this module.
|
||||||
class CalledProcessError(Exception):
|
class SubprocessError(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
|
class CalledProcessError(SubprocessError):
|
||||||
"""This exception is raised when a process run by check_call() or
|
"""This exception is raised when a process run by check_call() or
|
||||||
check_output() returns a non-zero exit status.
|
check_output() returns a non-zero exit status.
|
||||||
The exit status will be stored in the returncode attribute;
|
The exit status will be stored in the returncode attribute;
|
||||||
|
@ -362,7 +367,7 @@ class CalledProcessError(Exception):
|
||||||
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
|
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
|
||||||
|
|
||||||
|
|
||||||
class TimeoutExpired(Exception):
|
class TimeoutExpired(SubprocessError):
|
||||||
"""This exception is raised when the timeout expires while waiting for a
|
"""This exception is raised when the timeout expires while waiting for a
|
||||||
child process.
|
child process.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue