summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-09-21 21:12:30 (GMT)
committerFred Drake <fdrake@acm.org>2001-09-21 21:12:30 (GMT)
commitc69205526a2625af8e900ef47cbde1304338d514 (patch)
tree20bb995aff6bfb6cea8ced2eebef3c6396e0ebcc /Doc/lib
parent13af42822cdeed98096fef27c73d1661aa59f862 (diff)
downloadcpython-c69205526a2625af8e900ef47cbde1304338d514.zip
cpython-c69205526a2625af8e900ef47cbde1304338d514.tar.gz
cpython-c69205526a2625af8e900ef47cbde1304338d514.tar.bz2
Added reference to Tutorial section on user-defined exceptions for
information on defining new exceptions. This closes SF bug #443559.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libexcs.tex24
1 files changed, 15 insertions, 9 deletions
diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex
index 58d929a..5571086 100644
--- a/Doc/lib/libexcs.tex
+++ b/Doc/lib/libexcs.tex
@@ -10,7 +10,8 @@ Python 1.5 and newer versions, all standard exceptions have been
converted to class objects, and users are encouraged to do the same.
The exceptions are defined in the module \module{exceptions}. This
module never needs to be imported explicitly: the exceptions are
-provided in the built-in namespace.
+provided in the built-in namespace as well as the \module{exceptions}
+module.
Two distinct string objects with the same value are considered different
exceptions. This is done to force programmers to use exception names
@@ -47,6 +48,13 @@ situation in which the interpreter raises the same exception; but
beware that there is nothing to prevent user code from raising an
inappropriate error.
+The built-in exception classes can be sub-classed to define new
+exceptions; programmers are encouraged to at least derive new
+exceptions from the \exception{Exception} base class. More
+information on defining exceptions is available in the
+\citetitle[../tut/tut.html]{Python Tutorial} under the heading
+``User-defined Exceptions.''
+
\setindexsubitem{(built-in exception base class)}
The following exceptions are only used as base classes for other
@@ -254,12 +262,10 @@ Raised when an \keyword{assert} statement fails.
when reading the initial script or standard input (also
interactively).
-When class exceptions are used, instances of this class have
-atttributes \member{filename}, \member{lineno}, \member{offset} and
-\member{text} for easier access to the details; for string exceptions,
-the associated value is usually a tuple of the form
-\code{(message, (filename, lineno, offset, text))}.
-For class exceptions, \function{str()} returns only the message.
+ Instances of this class have atttributes \member{filename},
+ \member{lineno}, \member{offset} and \member{text} for easier access
+ to the details. \function{str()} of the exception instance returns
+ only the message.
\end{excdesc}
\begin{excdesc}{SystemError}
@@ -269,7 +275,7 @@ For class exceptions, \function{str()} returns only the message.
low-level terms).
You should report this to the author or maintainer of your Python
- interpreter. Be sure to report the version string of the Python
+ interpreter. Be sure to report the version of the Python
interpreter (\code{sys.version}; it is also printed at the start of an
interactive Python session), the exact error message (the exception's
associated value) and if possible the source of the program that
@@ -342,7 +348,7 @@ For class exceptions, \function{str()} returns only the message.
\end{excdesc}
-\setindexsubitem{(built-in warning category)}
+\setindexsubitem{(built-in warning)}
The following exceptions are used as warning categories; see the
\module{warnings} module for more information.