Merged revisions 87807,87820,87831,87859 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87807 | georg.brandl | 2011-01-06 20:28:18 +0100 (Do, 06 Jan 2011) | 1 line
#10846: fix typo.
........
r87820 | georg.brandl | 2011-01-07 19:28:45 +0100 (Fr, 07 Jan 2011) | 1 line
#10856: document (Base)Exception.args better.
........
r87831 | georg.brandl | 2011-01-07 21:58:25 +0100 (Fr, 07 Jan 2011) | 1 line
Fix indent.
........
r87859 | georg.brandl | 2011-01-08 10:45:43 +0100 (Sa, 08 Jan 2011) | 1 line
#10855: document close() semantics of wave objects.
........
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 7e94c0c..f9a6bee 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -26,7 +26,7 @@
The built-in exceptions listed below can be generated by the interpreter or
built-in functions. Except where mentioned, they have an "associated value"
-indicating the detailed cause of the error. This may be a string or a tuple
+indicating the detailed cause of the error. This may be a string or a tuple
containing several items of information (e.g., an error code and a string
explaining the code). The associated value is the second argument to the
:keyword:`raise` statement. If the exception class is derived from the standard
@@ -46,18 +46,35 @@
The following exceptions are only used as base classes for other exceptions.
-
.. exception:: BaseException
The base class for all built-in exceptions. It is not meant to be directly
- inherited by user-defined classes (for that use :exc:`Exception`). If
+ inherited by user-defined classes (for that, use :exc:`Exception`). If
:func:`str` or :func:`unicode` is called on an instance of this class, the
- representation of the argument(s) to the instance are returned or the empty
- string when there were no arguments. All arguments are stored in :attr:`args`
- as a tuple.
+ representation of the argument(s) to the instance are returned, or the empty
+ string when there were no arguments.
.. versionadded:: 2.5
+ .. attribute:: args
+
+ The tuple of arguments given to the exception constructor. Some built-in
+ exceptions (like :exc:`IOError`) expect a certain number of arguments and
+ assign a special meaning to the elements of this tuple, while others are
+ usually called only with a single string giving an error message.
+
+ .. method:: with_traceback(tb)
+
+ This method sets *tb* as the new traceback for the exception and returns
+ the exception object. It is usually used in exception handling code like
+ this::
+
+ try:
+ ...
+ except SomeException:
+ tb = sys.exc_info()[2]
+ raise OtherException(...).with_traceback(tb)
+
.. exception:: Exception