]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use raise X(y).
authorGeorg Brandl <georg@python.org>
Fri, 22 May 2009 07:23:32 +0000 (07:23 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 22 May 2009 07:23:32 +0000 (07:23 +0000)
Doc/tutorial/errors.rst

index e1d988ccd6f0b725bd3e40059903e35869a4e65c..ebec952648a206b1e97510e2c61407efa00e3268 100644 (file)
@@ -216,7 +216,7 @@ Raising Exceptions
 The :keyword:`raise` statement allows the programmer to force a specified
 exception to occur. For example::
 
-   >>> raise NameError, 'HiThere'
+   >>> raise NameError('HiThere')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    NameError: HiThere
@@ -231,7 +231,7 @@ handle it, a simpler form of the :keyword:`raise` statement allows you to
 re-raise the exception::
 
    >>> try:
-   ...     raise NameError, 'HiThere'
+   ...     raise NameError('HiThere')
    ... except NameError:
    ...     print 'An exception flew by!'
    ...     raise
@@ -263,7 +263,7 @@ directly or indirectly.  For example::
    ...     print 'My exception occurred, value:', e.value
    ...
    My exception occurred, value: 4
-   >>> raise MyError, 'oops!'
+   >>> raise MyError('oops!')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    __main__.MyError: 'oops!'