<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"api.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"api.html" title='Python/C API Reference Manual'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"node15.html" />
<link rel=
"prev" href=
"exceptionHandling.html" />
<link rel=
"parent" href=
"exceptionHandling.html" />
<link rel=
"next" href=
"node15.html" />
<meta name='aesop' content='information'
/>
<title>4.1 Standard Exceptions
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"4. Exception Handling"
href=
"exceptionHandling.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"4. Exception Handling"
href=
"exceptionHandling.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"4.2 Deprecation of String"
href=
"node15.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python/C API Reference Manual
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"exceptionHandling.html">4. Exception Handling
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"exceptionHandling.html">4. Exception Handling
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"node15.html">4.2 Deprecation of String
</A>
<!--End of Navigation Panel-->
<H1><A NAME=
"SECTION006100000000000000000"></A><A NAME=
"standardExceptions"></A>
All standard Python exceptions are available as global variables whose
names are
"<tt class="samp
">PyExc_</tt>" followed by the Python exception name. These
have the type
<tt class=
"ctype">PyObject*
</tt>; they are all class objects. For
completeness, here are all the variables:
<div class=
"center"><table class=
"realtable">
<th class=
"left" >C Name
</th>
<th class=
"left" >Python Name
</th>
<th class=
"center">Notes
</th>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_Exception
<a id='l2h-
126' xml:id='l2h-
126'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">Exception
</tt></td>
<td class=
"center">(
1)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_StandardError
<a id='l2h-
127' xml:id='l2h-
127'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">StandardError
</tt></td>
<td class=
"center">(
1)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_ArithmeticError
<a id='l2h-
128' xml:id='l2h-
128'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">ArithmeticError
</tt></td>
<td class=
"center">(
1)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_LookupError
<a id='l2h-
129' xml:id='l2h-
129'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">LookupError
</tt></td>
<td class=
"center">(
1)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_AssertionError
<a id='l2h-
130' xml:id='l2h-
130'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">AssertionError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_AttributeError
<a id='l2h-
131' xml:id='l2h-
131'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">AttributeError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_EOFError
<a id='l2h-
132' xml:id='l2h-
132'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">EOFError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_EnvironmentError
<a id='l2h-
133' xml:id='l2h-
133'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">EnvironmentError
</tt></td>
<td class=
"center">(
1)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_FloatingPointError
<a id='l2h-
134' xml:id='l2h-
134'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">FloatingPointError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_IOError
<a id='l2h-
135' xml:id='l2h-
135'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">IOError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_ImportError
<a id='l2h-
136' xml:id='l2h-
136'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">ImportError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_IndexError
<a id='l2h-
137' xml:id='l2h-
137'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">IndexError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_KeyError
<a id='l2h-
138' xml:id='l2h-
138'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">KeyError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_KeyboardInterrupt
<a id='l2h-
139' xml:id='l2h-
139'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">KeyboardInterrupt
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_MemoryError
<a id='l2h-
140' xml:id='l2h-
140'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">MemoryError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_NameError
<a id='l2h-
141' xml:id='l2h-
141'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">NameError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_NotImplementedError
<a id='l2h-
142' xml:id='l2h-
142'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">NotImplementedError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_OSError
<a id='l2h-
143' xml:id='l2h-
143'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">OSError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_OverflowError
<a id='l2h-
144' xml:id='l2h-
144'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">OverflowError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_ReferenceError
<a id='l2h-
145' xml:id='l2h-
145'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">ReferenceError
</tt></td>
<td class=
"center">(
2)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_RuntimeError
<a id='l2h-
146' xml:id='l2h-
146'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">RuntimeError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_SyntaxError
<a id='l2h-
147' xml:id='l2h-
147'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">SyntaxError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_SystemError
<a id='l2h-
148' xml:id='l2h-
148'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">SystemError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_SystemExit
<a id='l2h-
149' xml:id='l2h-
149'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">SystemExit
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_TypeError
<a id='l2h-
150' xml:id='l2h-
150'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">TypeError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_ValueError
<a id='l2h-
151' xml:id='l2h-
151'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">ValueError
</tt></td>
<td class=
"center"></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_WindowsError
<a id='l2h-
152' xml:id='l2h-
152'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">WindowsError
</tt></td>
<td class=
"center">(
3)
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"cdata">PyExc_ZeroDivisionError
<a id='l2h-
153' xml:id='l2h-
153'
></a></tt></td>
<td class=
"left" ><tt class=
"exception">ZeroDivisionError
</tt></td>
<td class=
"center"></td></tr></tbody>
<DT><STRONG>(
1)
</STRONG></DT>
<DD>This is a base class for other standard exceptions.
<DT><STRONG>(
2)
</STRONG></DT>
<DD>This is the same as
<tt class=
"exception">weakref.ReferenceError
</tt>.
<DT><STRONG>(
3)
</STRONG></DT>
<DD>Only defined on Windows; protect code that uses this by testing that
the preprocessor macro
<code>MS_WINDOWS
</code> is defined.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"4. Exception Handling"
href=
"exceptionHandling.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"4. Exception Handling"
href=
"exceptionHandling.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"4.2 Deprecation of String"
href=
"node15.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python/C API Reference Manual
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"exceptionHandling.html">4. Exception Handling
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"exceptionHandling.html">4. Exception Handling
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"node15.html">4.2 Deprecation of String
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.