Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c692055

Browse files
committed
Added reference to Tutorial section on user-defined exceptions for
information on defining new exceptions. This closes SF bug #443559.
1 parent 13af428 commit c692055

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

Doc/lib/libexcs.tex

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ \section{Built-in Exceptions}
1010
converted to class objects, and users are encouraged to do the same.
1111
The exceptions are defined in the module \module{exceptions}. This
1212
module never needs to be imported explicitly: the exceptions are
13-
provided in the built-in namespace.
13+
provided in the built-in namespace as well as the \module{exceptions}
14+
module.
1415

1516
Two distinct string objects with the same value are considered different
1617
exceptions. This is done to force programmers to use exception names
@@ -47,6 +48,13 @@ \section{Built-in Exceptions}
4748
beware that there is nothing to prevent user code from raising an
4849
inappropriate error.
4950

51+
The built-in exception classes can be sub-classed to define new
52+
exceptions; programmers are encouraged to at least derive new
53+
exceptions from the \exception{Exception} base class. More
54+
information on defining exceptions is available in the
55+
\citetitle[../tut/tut.html]{Python Tutorial} under the heading
56+
``User-defined Exceptions.''
57+
5058
\setindexsubitem{(built-in exception base class)}
5159

5260
The following exceptions are only used as base classes for other
@@ -254,12 +262,10 @@ \section{Built-in Exceptions}
254262
when reading the initial script or standard input (also
255263
interactively).
256264

257-
When class exceptions are used, instances of this class have
258-
atttributes \member{filename}, \member{lineno}, \member{offset} and
259-
\member{text} for easier access to the details; for string exceptions,
260-
the associated value is usually a tuple of the form
261-
\code{(message, (filename, lineno, offset, text))}.
262-
For class exceptions, \function{str()} returns only the message.
265+
Instances of this class have atttributes \member{filename},
266+
\member{lineno}, \member{offset} and \member{text} for easier access
267+
to the details. \function{str()} of the exception instance returns
268+
only the message.
263269
\end{excdesc}
264270

265271
\begin{excdesc}{SystemError}
@@ -269,7 +275,7 @@ \section{Built-in Exceptions}
269275
low-level terms).
270276

271277
You should report this to the author or maintainer of your Python
272-
interpreter. Be sure to report the version string of the Python
278+
interpreter. Be sure to report the version of the Python
273279
interpreter (\code{sys.version}; it is also printed at the start of an
274280
interactive Python session), the exact error message (the exception's
275281
associated value) and if possible the source of the program that
@@ -342,7 +348,7 @@ \section{Built-in Exceptions}
342348
\end{excdesc}
343349

344350

345-
\setindexsubitem{(built-in warning category)}
351+
\setindexsubitem{(built-in warning)}
346352

347353
The following exceptions are used as warning categories; see the
348354
\module{warnings} module for more information.

0 commit comments

Comments
 (0)