Changeset 391 for python/trunk/Doc/library/exceptions.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/exceptions.rst
r2 r391 27 27 The built-in exceptions listed below can be generated by the interpreter or 28 28 built-in functions. Except where mentioned, they have an "associated value" 29 indicating the detailed cause of the error. This may be a string or a tuple29 indicating the detailed cause of the error. This may be a string or a tuple 30 30 containing several items of information (e.g., an error code and a string 31 31 explaining the code). The associated value is the second argument to the … … 47 47 The following exceptions are only used as base classes for other exceptions. 48 48 49 50 49 .. exception:: BaseException 51 50 52 51 The base class for all built-in exceptions. It is not meant to be directly 53 inherited by user-defined classes (for that use :exc:`Exception`). If52 inherited by user-defined classes (for that, use :exc:`Exception`). If 54 53 :func:`str` or :func:`unicode` is called on an instance of this class, the 55 representation of the argument(s) to the instance are returned or the empty 56 string when there were no arguments. All arguments are stored in :attr:`args` 57 as a tuple. 54 representation of the argument(s) to the instance are returned, or the empty 55 string when there were no arguments. 58 56 59 57 .. versionadded:: 2.5 58 59 .. attribute:: args 60 61 The tuple of arguments given to the exception constructor. Some built-in 62 exceptions (like :exc:`IOError`) expect a certain number of arguments and 63 assign a special meaning to the elements of this tuple, while others are 64 usually called only with a single string giving an error message. 60 65 61 66 … … 81 86 arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, 82 87 :exc:`FloatingPointError`. 88 89 90 .. exception:: BufferError 91 92 Raised when a :ref:`buffer <bufferobjects>` related operation cannot be 93 performed. 83 94 84 95 … … 142 153 Raised when a floating point operation fails. This exception is always defined, 143 154 but can only be raised when Python is configured with the 144 :option:`--with-fpectl` option, or the :const:`WANT_SIGFPE_HANDLER` symbol is155 ``--with-fpectl`` option, or the :const:`WANT_SIGFPE_HANDLER` symbol is 145 156 defined in the :file:`pyconfig.h` file. 146 157 … … 210 221 rescued (by deleting some objects). The associated value is a string indicating 211 222 what kind of (internal) operation ran out of memory. Note that because of the 212 underlying memory management architecture (C's :c func:`malloc` function), the223 underlying memory management architecture (C's :c:func:`malloc` function), the 213 224 interpreter may not always be able to completely recover from this situation; it 214 225 nevertheless raises an exception so that a stack traceback can be printed, in … … 239 250 function returns a system-related error (not for illegal argument types or 240 251 other incidental errors). The :attr:`errno` attribute is a numeric error 241 code from :c data:`errno`, and the :attr:`strerror` attribute is the242 corresponding string, as would be printed by the C function :c func:`perror`.252 code from :c:data:`errno`, and the :attr:`strerror` attribute is the 253 corresponding string, as would be printed by the C function :c:func:`perror`. 243 254 See the module :mod:`errno`, which contains names for the error codes defined 244 255 by the underlying operating system. … … 302 313 303 314 315 .. exception:: IndentationError 316 317 Base class for syntax errors related to incorrect indentation. This is a 318 subclass of :exc:`SyntaxError`. 319 320 321 .. exception:: TabError 322 323 Raised when indentation contains an inconsistent use of tabs and spaces. 324 This is a subclass of :exc:`IndentationError`. 325 326 304 327 .. exception:: SystemError 305 328 … … 320 343 handled, the Python interpreter exits; no stack traceback is printed. If the 321 344 associated value is a plain integer, it specifies the system exit status (passed 322 to C's :c func:`exit` function); if it is ``None``, the exit status is zero; if345 to C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if 323 346 it has another type (such as a string), the object's value is printed and the 324 347 exit status is one. 325 348 326 Instances have an attribute :attr:` code` which is set to the proposed exit349 Instances have an attribute :attr:`!code` which is set to the proposed exit 327 350 status or error message (defaulting to ``None``). Also, this exception derives 328 351 directly from :exc:`BaseException` and not :exc:`StandardError`, since it is not … … 334 357 of losing control. The :func:`os._exit` function can be used if it is 335 358 absolutely positively necessary to exit immediately (for example, in the child 336 process after a call to :func:` fork`).359 process after a call to :func:`os.fork`). 337 360 338 361 The exception inherits from :exc:`BaseException` instead of :exc:`StandardError` … … 365 388 subclass of :exc:`ValueError`. 366 389 390 :exc:`UnicodeError` has attributes that describe the encoding or decoding 391 error. For example, ``err.object[err.start:err.end]`` gives the particular 392 invalid input that the codec failed on. 393 394 .. attribute:: encoding 395 396 The name of the encoding that raised the error. 397 398 .. attribute:: reason 399 400 A string describing the specific codec error. 401 402 .. attribute:: object 403 404 The object the codec was attempting to encode or decode. 405 406 .. attribute:: start 407 408 The first index of invalid data in :attr:`object`. 409 410 .. attribute:: end 411 412 The index after the last invalid data in :attr:`object`. 413 367 414 .. versionadded:: 2.0 368 415 … … 407 454 408 455 Raised when a Windows-specific error occurs or when the error number does not 409 correspond to an :c data:`errno` value. The :attr:`winerror` and456 correspond to an :c:data:`errno` value. The :attr:`winerror` and 410 457 :attr:`strerror` values are created from the return values of the 411 :c func:`GetLastError` and :cfunc:`FormatMessage` functions from the Windows458 :c:func:`GetLastError` and :c:func:`FormatMessage` functions from the Windows 412 459 Platform API. The :attr:`errno` value maps the :attr:`winerror` value to 413 460 corresponding ``errno.h`` values. This is a subclass of :exc:`OSError`. … … 416 463 417 464 .. versionchanged:: 2.5 418 Previous versions put the :c func:`GetLastError` codes into :attr:`errno`.465 Previous versions put the :c:func:`GetLastError` codes into :attr:`errno`. 419 466 420 467
Note:
See TracChangeset
for help on using the changeset viewer.