]> granicus.if.org Git - python/commitdiff
More \exception fixes.
authorGeorg Brandl <georg@python.org>
Fri, 17 Mar 2006 16:26:31 +0000 (16:26 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 17 Mar 2006 16:26:31 +0000 (16:26 +0000)
18 files changed:
Doc/lib/compiler.tex
Doc/lib/libarray.tex
Doc/lib/libcgi.tex
Doc/lib/libcodecs.tex
Doc/lib/libcookielib.tex
Doc/lib/libitertools.tex
Doc/lib/libnntplib.tex
Doc/lib/liboptparse.tex
Doc/lib/libossaudiodev.tex
Doc/lib/libpycompile.tex
Doc/lib/libre.tex
Doc/lib/libsets.tex
Doc/lib/libshutil.tex
Doc/lib/libstdtypes.tex
Doc/lib/libsubprocess.tex
Doc/lib/liburllib2.tex
Doc/lib/libzipimport.tex
Doc/lib/xmldomminidom.tex

index e619a9af36b5f381e299b6bf047af331596d73d9..f0926e70017677fc67487cdcd44807a3a72fcc4c 100644 (file)
@@ -40,9 +40,9 @@ modules contained in the package.
 
 \begin{funcdesc}{parse}{buf}
 Returns an abstract syntax tree for the Python source code in \var{buf}.
-The function raises SyntaxError if there is an error in the source
-code.  The return value is a \class{compiler.ast.Module} instance that
-contains the tree.  
+The function raises \exception{SyntaxError} if there is an error in the
+source code.  The return value is a \class{compiler.ast.Module} instance
+that contains the tree.  
 \end{funcdesc}
 
 \begin{funcdesc}{parseFile}{path}
index 897310df99fe977deb1bc5926e9061ce7513ca04..eaf58884e5b7f5a134e3a4cec7f62a9a4f7bd7de 100644 (file)
@@ -139,8 +139,8 @@ file using the \method{fromfile()} method).
 \end{methoddesc}
 
 \begin{methoddesc}[array]{fromunicode}{s}
-Extends this array with data from the given unicode string.
-The array must be a type 'u' array; otherwise a ValueError
+Extends this array with data from the given unicode string.  The array
+must be a type \code{'u'} array; otherwise a \exception{ValueError}
 is raised.  Use \samp{array.fromstring(ustr.decode(enc))} to
 append Unicode data to an array of some other type.
 \end{methoddesc}
@@ -197,8 +197,8 @@ be written to a file by the \method{tofile()} method.)
 
 \begin{methoddesc}[array]{tounicode}{}
 Convert the array to a unicode string.  The array must be
-a type 'u' array; otherwise a ValueError is raised.  Use
-array.tostring().decode(enc) to obtain a unicode string
+a type \code{'u'} array; otherwise a \exception{ValueError} is raised.
+Use \samp{array.tostring().decode(enc)} to obtain a unicode string
 from an array of some other type.
 \end{methoddesc}
 
index cd6f58a6069deca866d5f3c7e75f36aeb5561807..1dd7e03f39171342c283ee4240ddf9e2b50f594c 100644 (file)
@@ -323,7 +323,7 @@ not included.
 
 The optional argument \var{strict_parsing} is a flag indicating what
 to do with parsing errors.  If false (the default), errors
-are silently ignored.  If true, errors raise a ValueError
+are silently ignored.  If true, errors raise a \exception{ValueError}
 exception.
 
 Use the \function{\refmodule{urllib}.urlencode()} function to convert
@@ -347,7 +347,7 @@ not included.
 
 The optional argument \var{strict_parsing} is a flag indicating what
 to do with parsing errors.  If false (the default), errors
-are silently ignored.  If true, errors raise a ValueError
+are silently ignored.  If true, errors raise a \exception{ValueError}
 exception.
 
 Use the \function{\refmodule{urllib}.urlencode()} function to convert
index ac617438202a57e919f032f24cfed0ab471c12a7..951a68ae7ba35eb02cc08f9c747b03a335a38031 100644 (file)
@@ -152,7 +152,7 @@ unencodable part of the input and a position where encoding should
 continue. The encoder will encode the replacement and continue encoding
 the original input at the specified position. Negative position values
 will be treated as being relative to the end of the input string. If the
-resulting position is out of bound an IndexError will be raised.
+resulting position is out of bound an \exception{IndexError} will be raised.
 
 Decoding and translating works similar, except \exception{UnicodeDecodeError}
 or \exception{UnicodeTranslateError} will be passed to the handler and
@@ -696,10 +696,10 @@ transformation can be done (these methods are also called encodings).
 The simplest method is to map the codepoints 0-255 to the bytes
 \code{0x0}-\code{0xff}. This means that a unicode object that contains 
 codepoints above \code{U+00FF} can't be encoded with this method (which 
-is called \code{'latin-1'} or \code{'iso-8859-1'}). unicode.encode() will 
-raise a UnicodeEncodeError that looks like this: \samp{UnicodeEncodeError:
-'latin-1' codec can't encode character u'\e u1234' in position 3: ordinal
-not in range(256)}.
+is called \code{'latin-1'} or \code{'iso-8859-1'}).
+\function{unicode.encode()} will raise a \exception{UnicodeEncodeError}
+that looks like this: \samp{UnicodeEncodeError: 'latin-1' codec can't
+encode character u'\e u1234' in position 3: ordinal not in range(256)}.
 
 There's another group of encodings (the so called charmap encodings)
 that choose a different subset of all unicode code points and how
index a35f97d21ca07a7562930e6f526d942f5a78ea14..ef2d833b50c65df45c4898d82b0d681a81c5a91d 100644 (file)
@@ -249,7 +249,7 @@ anyway, unless you ask otherwise by passing a true
     ignore_discard=\constant{False}, ignore_expires=\constant{False}}
 Save cookies to a file.
 
-This base class raises \class{NotImplementedError}.  Subclasses may
+This base class raises \exception{NotImplementedError}.  Subclasses may
 leave this method unimplemented.
 
 \var{filename} is the name of file in which to save cookies.  If
index 421d647404a786654900ad57cfaf06462805fa91..904a19aca54006e6e099abd70072a0b25318752e 100644 (file)
@@ -281,7 +281,8 @@ by functions or loops that truncate the stream.
   \end{verbatim}
 
   \versionchanged[When no iterables are specified, returns a zero length
-                  iterator instead of raising a TypeError exception]{2.4}  
+                  iterator instead of raising a \exception{TypeError}
+                 exception]{2.4}
 \end{funcdesc}
 
 \begin{funcdesc}{repeat}{object\optional{, times}}
index 7f14deeac77eeee34cb2830cebb43f72643246b7..10330ed9b8064117b9c11782a4b63de82b886632 100644 (file)
@@ -68,48 +68,48 @@ flag \var{readermode} is true, then a \samp{mode reader} command is
 sent before authentication is performed.  Reader mode is sometimes
 necessary if you are connecting to an NNTP server on the local machine
 and intend to call reader-specific commands, such as \samp{group}.  If
-you get unexpected \code{NNTPPermanentError}s, you might need to set
+you get unexpected \exception{NNTPPermanentError}s, you might need to set
 \var{readermode}.  \var{readermode} defaults to \code{None}.
 \var{usenetrc} defaults to \code{True}.
 
 \versionchanged[\var{usenetrc} argument added]{2.4}
 \end{classdesc}
 
-\begin{classdesc}{NNTPError}{}
-Derived from the standard exception \code{Exception}, this is the base
-class for all exceptions raised by the \code{nntplib} module.
-\end{classdesc}
+\begin{excdesc}{NNTPError}
+Derived from the standard exception \exception{Exception}, this is the
+base class for all exceptions raised by the \module{nntplib} module.
+\end{excdesc}
 
-\begin{classdesc}{NNTPReplyError}{}
+\begin{excdesc}{NNTPReplyError}
 Exception raised when an unexpected reply is received from the
 server.  For backwards compatibility, the exception \code{error_reply}
 is equivalent to this class.
-\end{classdesc}
+\end{excdesc}
 
-\begin{classdesc}{NNTPTemporaryError}{}
+\begin{excdesc}{NNTPTemporaryError}
 Exception raised when an error code in the range 400--499 is
 received.  For backwards compatibility, the exception
 \code{error_temp} is equivalent to this class.
-\end{classdesc}
+\end{excdesc}
 
-\begin{classdesc}{NNTPPermanentError}{}
+\begin{excdesc}{NNTPPermanentError}
 Exception raised when an error code in the range 500--599 is
 received.  For backwards compatibility, the exception
 \code{error_perm} is equivalent to this class.
-\end{classdesc}
+\end{excdesc}
 
-\begin{classdesc}{NNTPProtocolError}{}
+\begin{excdesc}{NNTPProtocolError}
 Exception raised when a reply is received from the server that does
 not begin with a digit in the range 1--5.  For backwards
 compatibility, the exception \code{error_proto} is equivalent to this
 class.
-\end{classdesc}
+\end{excdesc}
 
-\begin{classdesc}{NNTPDataError}{}
+\begin{excdesc}{NNTPDataError}
 Exception raised when there is some error in the response data.  For
 backwards compatibility, the exception \code{error_data} is
 equivalent to this class.
-\end{classdesc}
+\end{excdesc}
 
 
 \subsection{NNTP Objects \label{nntp-objects}}
index 4ab325bc25dcfe32cfd5be675bc60f0072dddfd3..8aca501f750a5b9999a013f1bbd46efab9fe88fc 100644 (file)
@@ -100,8 +100,8 @@ options; the traditional \UNIX{} syntax is a hyphen (``-'') followed by a
 single letter, e.g. \code{"-x"} or \code{"-F"}.  Also, traditional \UNIX{}
 syntax allows multiple options to be merged into a single argument,
 e.g.  \code{"-x -F"} is equivalent to \code{"-xF"}.  The GNU project
-introduced \code{"-{}-"} followed by a series of hyphen-separated words,
-e.g. \code{"-{}-file"} or \code{"-{}-dry-run"}.  These are the only two option
+introduced \code{"{--}"} followed by a series of hyphen-separated words,
+e.g. \code{"{--}file"} or \code{"{--}dry-run"}.  These are the only two option
 syntaxes provided by \module{optparse}.
 
 Some other option syntaxes that the world has seen include:
@@ -170,7 +170,7 @@ For example, consider this hypothetical command-line:
 prog -v --report /tmp/report.txt foo bar
 \end{verbatim}
 
-\code{"-v"} and \code{"-{}-report"} are both options.  Assuming that
+\code{"-v"} and \code{"{--}report"} are both options.  Assuming that
 \longprogramopt{report} takes one argument, \code{"/tmp/report.txt"} is an option
 argument.  \code{"foo"} and \code{"bar"} are positional arguments.
 
@@ -587,7 +587,7 @@ programmer errors and user errors.  Programmer errors are usually
 erroneous calls to \code{parse.add{\_}option()}, e.g. invalid option strings,
 unknown option attributes, missing option attributes, etc.  These are
 dealt with in the usual way: raise an exception (either
-\code{optparse.OptionError} or \code{TypeError}) and let the program crash.
+\exception{optparse.OptionError} or \exception{TypeError}) and let the program crash.
 
 Handling user errors is much more important, since they are guaranteed
 to happen no matter how stable your code is.  \module{optparse} can automatically
@@ -1019,9 +1019,9 @@ callback) as-is.
 
 Integer arguments are passed to \code{int()} to convert them to Python
 integers.  If \code{int()} fails, so will \module{optparse}, although with a more
-useful error message.  (Internally, \module{optparse} raises OptionValueError;
-OptionParser catches this exception higher up and terminates your
-program with a useful error message.)
+useful error message.  (Internally, \module{optparse} raises
+\exception{OptionValueError}; OptionParser catches this exception higher
+up and terminates your program with a useful error message.)
 
 Likewise, \code{float} arguments are passed to \code{float()} for conversion,
 \code{long} arguments to \code{long()}, and \code{complex} arguments to
@@ -1032,7 +1032,7 @@ arguments.
 option attribute (a sequence of strings) defines the set of allowed
 option arguments.  \code{optparse.option.check{\_}choice()} compares
 user-supplied option arguments against this master list and raises
-OptionValueError if an invalid string is given.
+\exception{OptionValueError} if an invalid string is given.
 
 
 \subsubsection{Querying and manipulating your option parser\label{optparse-querying-manipulating-option-parser}}
@@ -1052,7 +1052,7 @@ that option is removed.  If that option provided any other
 option strings, all of those option strings become invalid.
 
 If \code{opt{\_}str} does not occur in any option belonging to this
-OptionParser, raises ValueError.
+OptionParser, raises \exception{ValueError}.
 \end{description}
 
 
@@ -1087,7 +1087,7 @@ The available conflict-handling mechanisms are:
 \begin{description}
 \item[\code{error} (default)]
 assume option conflicts are a programming error and raise 
-OptionConflictError
+\exception{OptionConflictError}
 \item[\code{resolve}]
 resolve option conflicts intelligently (see below)
 \end{description}
@@ -1260,7 +1260,7 @@ is a dictionary of arbitrary keyword arguments supplied via
 
 \subsubsection{Raising errors in a callback\label{optparse-raising-errors-in-callback}}
 
-The callback function should raise OptionValueError if there are any
+The callback function should raise \exception{OptionValueError} if there are any
 problems with the option or its argument(s).  \module{optparse} catches this and
 terminates the program, printing the error message you supply to
 stderr.  Your message should be clear, concise, accurate, and mention
index ec79e9e003da87712e517509e26423544f2e254d..223cf2892d034abb0261529a01de5769d4cb5469 100644 (file)
@@ -311,7 +311,7 @@ The mixer object provides two file-like methods:
 
 \begin{methoddesc}[mixer device]{close}{}
 This method closes the open mixer device file.  Any further attempts to
-use the mixer after this file is closed will raise an IOError.
+use the mixer after this file is closed will raise an \exception{IOError}.
 \end{methoddesc}
 
 \begin{methoddesc}[mixer device]{fileno}{}
index 04581918dbdc4f96463b9162749a6c88df1bdeff..85f0aaa8bbcb46ab483f7825abe75f7d2a9b86de 100644 (file)
@@ -30,9 +30,10 @@ Exception raised when an error occurs while attempting to compile the file.
   \code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
   current interpreter).  If \var{dfile} is specified, it is used as
   the name of the source file in error messages instead of \var{file}. 
-  If \var{doraise} = True, a PyCompileError is raised when an error is 
-  encountered while compiling \var{file}. If \var{doraise} = False (the default), 
-  an error string is written to sys.stderr, but no exception is raised.
+  If \var{doraise} is true, a \exception{PyCompileError} is raised when
+  an error is encountered while compiling \var{file}. If \var{doraise}
+  is false (the default), an error string is written to \code{sys.stderr},
+  but no exception is raised.
 \end{funcdesc}
 
 \begin{funcdesc}{main}{\optional{args}}
index 0fd57960fd91cf0600835efebdac4b248efbfdfa..1404e09b197b25d01bacb822f72ca43bce9e9928 100644 (file)
@@ -931,7 +931,7 @@ The equivalent regular expression would be
 \leftline{\strong{Avoiding recursion}}
 
 If you create regular expressions that require the engine to perform a
-lot of recursion, you may encounter a RuntimeError exception with
+lot of recursion, you may encounter a \exception{RuntimeError} exception with
 the message \code{maximum recursion limit} exceeded. For example,
 
 \begin{verbatim}
index dd85ec76357a7e9b54d357357f4d3001950e68bc..22bf34bfb4f728bf7397adbbe95f3dbfc0a2acfe 100644 (file)
@@ -151,12 +151,13 @@ but not found in \class{ImmutableSet}:
   \lineiii{\var{s}.add(\var{x})}{}
          {add element \var{x} to set \var{s}}
   \lineiii{\var{s}.remove(\var{x})}{}
-         {remove \var{x} from set \var{s}; raises KeyError if not present}
+         {remove \var{x} from set \var{s}; raises \exception{KeyError}
+         if not present}
   \lineiii{\var{s}.discard(\var{x})}{}
          {removes \var{x} from set \var{s} if present}
   \lineiii{\var{s}.pop()}{}
          {remove and return an arbitrary element from \var{s}; raises
-         KeyError if empty}
+         \exception{KeyError} if empty}
   \lineiii{\var{s}.clear()}{}
          {remove all elements from set \var{s}}
 \end{tableiii}
index a217150cb4c6135d62b1718376d6baa44b09787b..449d7414f38b248d524c3e493cec04ef247f5567 100644 (file)
@@ -73,18 +73,18 @@ file type and creator codes will not be correct.
   If \var{symlinks} is true, symbolic links in
   the source tree are represented as symbolic links in the new tree;
   if false or omitted, the contents of the linked files are copied to
-  the new tree.  If exception(s) occur, an Error is raised
+  the new tree.  If exception(s) occur, an \exception{Error} is raised
   with a list of reasons.
 
   The source code for this should be considered an example rather than 
   a tool.
 
-  \versionchanged[Error is raised if any exceptions occur during copying,
-  rather than printing a message]{2.3}
+  \versionchanged[\exception{Error} is raised if any exceptions occur during
+                  copying, rather than printing a message]{2.3}
 
   \versionchanged[Create intermediate directories needed to create \var{dst},
-  rather than raising an error. Copy permissions and times of directories using
-  \function{copystat()}]{2.5}
+                  rather than raising an error. Copy permissions and times of
+                 directories using \function{copystat()}]{2.5}
 
 \end{funcdesc}
 
index 5d153758b92d45607d2f9be780b4d46dd99d978f..55e7ee6c2d78a0d68ae38620e163ab19f43d8fb8 100644 (file)
@@ -1278,7 +1278,8 @@ that do not apply to immutable instances of \class{frozenset}:
   \lineiii{\var{s}.add(\var{x})}{}
          {add element \var{x} to set \var{s}}
   \lineiii{\var{s}.remove(\var{x})}{}
-         {remove \var{x} from set \var{s}; raises KeyError if not present}
+         {remove \var{x} from set \var{s}; raises \exception{KeyError}
+         if not present}
   \lineiii{\var{s}.discard(\var{x})}{}
          {removes \var{x} from set \var{s} if present}
   \lineiii{\var{s}.pop()}{}
@@ -1789,14 +1790,14 @@ class, respectively.  When a method is unbound, its \code{im_self}
 attribute will be \code{None} and if called, an explicit \code{self}
 object must be passed as the first argument.  In this case,
 \code{self} must be an instance of the unbound method's class (or a
-subclass of that class), otherwise a \code{TypeError} is raised.
+subclass of that class), otherwise a \exception{TypeError} is raised.
 
 Like function objects, methods objects support getting
 arbitrary attributes.  However, since method attributes are actually
 stored on the underlying function object (\code{meth.im_func}),
 setting method attributes on either bound or unbound methods is
 disallowed.  Attempting to set a method attribute results in a
-\code{TypeError} being raised.  In order to set a method attribute,
+\exception{TypeError} being raised.  In order to set a method attribute,
 you need to explicitly set it on the underlying function object:
 
 \begin{verbatim}
index f48b29b7581516b4b7e7c7cb4a6003d384755658..4417797dd5d2e6a97cd9dc948fa2531d435c9e2f 100644 (file)
@@ -135,8 +135,8 @@ The arguments are the same as for the Popen constructor.  Example:
 
 \begin{funcdesc}{check_call}{*popenargs, **kwargs}
 Run command with arguments.  Wait for command to complete. If the exit
-code was zero then return, otherwise raise CalledProcessError.  The
-CalledProcessError object will have the return code in the
+code was zero then return, otherwise raise \exception{CalledProcessError.}
+The \exception{CalledProcessError} object will have the return code in the
 \member{errno} attribute.
 
 The arguments are the same as for the Popen constructor.  Example:
index 706c54b4e8c22c37aee849a1dcd9fd5cdb587ad8..e0c45683d0be2517c1a5b5ecd3b0b006dc062179 100644 (file)
@@ -384,7 +384,7 @@ determined by sorting the handler instances.
     \method{\var{protocol}_open()} are called to handle the request.
     This stage ends when a handler either returns a
     non-\constant{None} value (ie. a response), or raises an exception
-    (usually URLError).  Exceptions are allowed to propagate.
+    (usually \exception{URLError}).  Exceptions are allowed to propagate.
 
     In fact, the above algorithm is first tried for methods named
     \method{default_open}.  If all such methods return
index 0a60b29eb4a4f8464377780d988b0f2a3645e1ed..770ea21dca5a3d2c3c8f60be23105a8bd674813c 100644 (file)
@@ -69,8 +69,8 @@ The available attributes of this module are:
 
 \begin{classdesc}{zipimporter}{archivepath} 
   Create a new zipimporter instance. \var{archivepath} must be a path to
-  a zipfile.  \class{ZipImportError} is raised if \var{archivepath} doesn't
-  point to a valid ZIP archive.
+  a zipfile.  \exception{ZipImportError} is raised if \var{archivepath}
+  doesn't point to a valid ZIP archive.
 \end{classdesc}
 
 \begin{methoddesc}{find_module}{fullname\optional{, path}}
@@ -83,7 +83,7 @@ The available attributes of this module are:
 
 \begin{methoddesc}{get_code}{fullname}
   Return the code object for the specified module. Raise
-  \class{ZipImportError} if the module couldn't be found.
+  \exception{ZipImportError} if the module couldn't be found.
 \end{methoddesc}
 
 \begin{methoddesc}{get_data}{pathname}
@@ -93,20 +93,20 @@ The available attributes of this module are:
 
 \begin{methoddesc}{get_source}{fullname}
   Return the source code for the specified module. Raise
-  \class{ZipImportError} if the module couldn't be found, return
+  \exception{ZipImportError} if the module couldn't be found, return
   \constant{None} if the archive does contain the module, but has
   no source for it.
 \end{methoddesc}
 
 \begin{methoddesc}{is_package}{fullname}
   Return True if the module specified by \var{fullname} is a package.
-  Raise \class{ZipImportError} if the module couldn't be found.
+  Raise \exception{ZipImportError} if the module couldn't be found.
 \end{methoddesc}
 
 \begin{methoddesc}{load_module}{fullname}
   Load the module specified by \var{fullname}. \var{fullname} must be the
   fully qualified (dotted) module name. It returns the imported
-  module, or raises \class{ZipImportError} if it wasn't found.
+  module, or raises \exception{ZipImportError} if it wasn't found.
 \end{methoddesc}
 
 \subsection{Examples}
index f7657eb32986e2ca30ef3e1211a08d3b9e9ec942..093915fc812202fbef6646e52cbb3a1b80d0b3a5 100644 (file)
@@ -165,7 +165,7 @@ XML.
 
 With an explicit \var{encoding} argument, the result is a byte string
 in the specified encoding. It is recommended that this argument is
-always specified. To avoid UnicodeError exceptions in case of
+always specified. To avoid \exception{UnicodeError} exceptions in case of
 unrepresentable text data, the encoding argument should be specified
 as "utf-8".