[Python-checkins] cpython (merge 3.5 -> default): merge

raymond.hettinger python-checkins at python.org
Fri Aug 12 12:44:25 EDT 2016


https://hg.python.org/cpython/rev/0c3adb3b0570
changeset:   102622:0c3adb3b0570
parent:      102620:4d4b5b978b7e
parent:      102621:6fdd29a9d5d4
user:        Raymond Hettinger <python at rcn.com>
date:        Fri Aug 12 09:44:18 2016 -0700
summary:
  merge

files:
  Doc/tutorial/errors.rst |  24 +-----------------------
  1 files changed, 1 insertions(+), 23 deletions(-)


diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -244,29 +244,7 @@
 
 Programs may name their own exceptions by creating a new exception class (see
 :ref:`tut-classes` for more about Python classes).  Exceptions should typically
-be derived from the :exc:`Exception` class, either directly or indirectly.  For
-example::
-
-   >>> class MyError(Exception):
-   ...     def __init__(self, value):
-   ...         self.value = value
-   ...     def __str__(self):
-   ...         return repr(self.value)
-   ...
-   >>> try:
-   ...     raise MyError(2*2)
-   ... except MyError as e:
-   ...     print('My exception occurred, value:', e.value)
-   ...
-   My exception occurred, value: 4
-   >>> raise MyError('oops!')
-   Traceback (most recent call last):
-     File "<stdin>", line 1, in ?
-   __main__.MyError: 'oops!'
-
-In this example, the default :meth:`__init__` of :class:`Exception` has been
-overridden.  The new behavior simply creates the *value* attribute.  This
-replaces the default behavior of creating the *args* attribute.
+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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list