]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34538: Remove Exception subclassing from tutorial (GH-30361)
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Mon, 3 Jan 2022 22:52:09 +0000 (00:52 +0200)
committerGitHub <noreply@github.com>
Mon, 3 Jan 2022 22:52:09 +0000 (14:52 -0800)
Remove the bit about subclassing exceptions.

Documentation PR can skip the NEWS label.

Automerge-Triggered-By: GH:iritkatriel
Doc/tutorial/errors.rst

index f2490d65db5d4934009df3d87ff20ed51065551f..3f09db21040680cc2a3ffc88cc181e5a6f1d9a10 100644 (file)
@@ -329,41 +329,7 @@ be derived from the :exc:`Exception` class, either directly or indirectly.
 
 Exception classes can be defined which do anything any other class can do, but
 are usually kept simple, often only offering a number of attributes that allow
-information about the error to be extracted by handlers for the exception.  When
-creating a module that can raise several distinct errors, a common practice is
-to create a base class for exceptions defined by that module, and subclass that
-to create specific exception classes for different error conditions::
-
-   class Error(Exception):
-       """Base class for exceptions in this module."""
-       pass
-
-   class InputError(Error):
-       """Exception raised for errors in the input.
-
-       Attributes:
-           expression -- input expression in which the error occurred
-           message -- explanation of the error
-       """
-
-       def __init__(self, expression, message):
-           self.expression = expression
-           self.message = message
-
-   class TransitionError(Error):
-       """Raised when an operation attempts a state transition that's not
-       allowed.
-
-       Attributes:
-           previous -- state at beginning of transition
-           next -- attempted new state
-           message -- explanation of why the specific transition is not allowed
-       """
-
-       def __init__(self, previous, next, message):
-           self.previous = previous
-           self.next = next
-           self.message = message
+information about the error to be extracted by handlers for the exception.
 
 Most exceptions are defined with names that end in "Error", similar to the
 naming of the standard exceptions.