Python Exceptions


Table B.12 lists exceptions in Python.

Table B.12. Python Built-In Exceptions

Exception Name

Description

BaseException[a]

Root class for all exceptions

SystemExit[b]

Request termination of Python interpreter

KeyboardInterrupt[c]

User interrupted execution (usually by typing ^C)

Exception[d]

Root class for regular exceptions

StopIteration[e]

Iteration has no further values

GeneratorExit[a]

Exception sent to generator to tell it to quit

SystemExit[f]

Request termination of Python interpreter

StandardError[d]

Base class for all standard built-in exceptions

ArithmeticError[d]

Base class for all numeric calculation errors

FloatingPointError[d]

Error in floating point calculation

OverflowError

Calculation exceeded maximum limit for numerical type

ZeroDivisionError

Division (or modulus) by zero error (all numeric types)

AssertionError[d]

Failure of assert statement

AttributeError

No such object attribute

EOFError

End-of-file marker reached without input from built-in

EnvironmentError

Base class for operating system environment errors

IOError

Failure of input/output operation

OSError

Operating system error

WindowsError

MS Windows system call failure

ImportError

Failure to import module or object

KeyboardInterrupt[f]

User interrupted execution (usually by typing ^C)

LookupError[d]

Base class for invalid data lookup errors

IndexError

No such index in sequence

KeyError

No such key in mapping

MemoryError

Out-of-memory error (non-fatal to Python interpreter)

NameError

Undeclared/uninitialized object (non-attribute)

UnboundLocalError

Access of an uninitialized local variable

ReferenceError

Weak reference tried to access a garbage-collected object

RuntimeError

Generic default error during execution

NotImplementedError

Unimplemented method

SyntaxError

Error in Python syntax

IndentationError

Improper indentation

TabError[g]

Improper mixture of TABs and spaces

SystemError

Generic interpreter system error

TypeError

Invalid operation for type

ValueError

Invalid argument given

UnicodeError[h]

Unicode-related error

UnicodeDecodeError

Unicode error during decoding

UnicodeEncodeError

Unicode error during encoding

UnicodeTranslate

Unicode error during translation

Error[i]

 

Warning[j]

Root class for all warnings

DeprecationWarning[j]

Warning about deprecated features

FutureWarning[i]

Warning about constructs that will change semantically in the future

OverflowWarning[k]

Old warning for auto-long upgrade

PendingDeprecationWarning[i]

Warning about features that will be deprecated in the future

RuntimeWarning[j]

Warning about dubious runtime behavior

SyntaxWarning[j]

Warning about dubious syntax

UserWarning[j]

Warning generated by user code


[a] New in Python 2.5.

[b] Prior to Python 2.5, SystemExit subclassed Exception .

[c] Prior to Python 2.5, KeyboardInterrupt subclassed StandardError.

[d] New in Python 1.5, the release when class-based exceptions replaced strings.

[e] New in Python 2.2.

[f] Only for Python 1.5 through 2.4.x.

[g] New in Python 2.0.

[h] New in Python 1.6.

[i] New in Python 2.3.

[j] New in Python 2.1.

[k] New in Python 2.2 but removed in Python 2.4.



Core Python Programming
Core Python Programming (2nd Edition)
ISBN: 0132269937
EAN: 2147483647
Year: 2004
Pages: 334
Authors: Wesley J Chun

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net