| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="api.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="api.html" title='Python/C API Reference Manual' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="node15.html" /> |
| 13 | <link rel="prev" href="exceptionHandling.html" /> |
| 14 | <link rel="parent" href="exceptionHandling.html" /> |
| 15 | <link rel="next" href="node15.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>4.1 Standard Exceptions </title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="4. Exception Handling" |
| 25 | href="exceptionHandling.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="4. Exception Handling" |
| 28 | href="exceptionHandling.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="4.2 Deprecation of String" |
| 31 | href="node15.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python/C API Reference Manual</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><img src='../icons/blank.png' |
| 38 | border='0' height='32' alt='' width='32' /></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="exceptionHandling.html">4. Exception Handling</A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="exceptionHandling.html">4. Exception Handling</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="node15.html">4.2 Deprecation of String</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION006100000000000000000"></A><A NAME="standardExceptions"></A> |
| 56 | <BR> |
| 57 | 4.1 Standard Exceptions |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | All standard Python exceptions are available as global variables whose |
| 62 | names are "<tt class="samp">PyExc_</tt>" followed by the Python exception name. These |
| 63 | have the type <tt class="ctype">PyObject*</tt>; they are all class objects. For |
| 64 | completeness, here are all the variables: |
| 65 | |
| 66 | <P> |
| 67 | <div class="center"><table class="realtable"> |
| 68 | <thead> |
| 69 | <tr> |
| 70 | <th class="left" >C Name</th> |
| 71 | <th class="left" >Python Name</th> |
| 72 | <th class="center">Notes</th> |
| 73 | </tr> |
| 74 | </thead> |
| 75 | <tbody> |
| 76 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_Exception<a id='l2h-126' xml:id='l2h-126'></a></tt></td> |
| 77 | <td class="left" ><tt class="exception">Exception</tt></td> |
| 78 | <td class="center">(1)</td></tr> |
| 79 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_StandardError<a id='l2h-127' xml:id='l2h-127'></a></tt></td> |
| 80 | <td class="left" ><tt class="exception">StandardError</tt></td> |
| 81 | <td class="center">(1)</td></tr> |
| 82 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_ArithmeticError<a id='l2h-128' xml:id='l2h-128'></a></tt></td> |
| 83 | <td class="left" ><tt class="exception">ArithmeticError</tt></td> |
| 84 | <td class="center">(1)</td></tr> |
| 85 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_LookupError<a id='l2h-129' xml:id='l2h-129'></a></tt></td> |
| 86 | <td class="left" ><tt class="exception">LookupError</tt></td> |
| 87 | <td class="center">(1)</td></tr> |
| 88 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_AssertionError<a id='l2h-130' xml:id='l2h-130'></a></tt></td> |
| 89 | <td class="left" ><tt class="exception">AssertionError</tt></td> |
| 90 | <td class="center"></td></tr> |
| 91 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_AttributeError<a id='l2h-131' xml:id='l2h-131'></a></tt></td> |
| 92 | <td class="left" ><tt class="exception">AttributeError</tt></td> |
| 93 | <td class="center"></td></tr> |
| 94 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_EOFError<a id='l2h-132' xml:id='l2h-132'></a></tt></td> |
| 95 | <td class="left" ><tt class="exception">EOFError</tt></td> |
| 96 | <td class="center"></td></tr> |
| 97 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_EnvironmentError<a id='l2h-133' xml:id='l2h-133'></a></tt></td> |
| 98 | <td class="left" ><tt class="exception">EnvironmentError</tt></td> |
| 99 | <td class="center">(1)</td></tr> |
| 100 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_FloatingPointError<a id='l2h-134' xml:id='l2h-134'></a></tt></td> |
| 101 | <td class="left" ><tt class="exception">FloatingPointError</tt></td> |
| 102 | <td class="center"></td></tr> |
| 103 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_IOError<a id='l2h-135' xml:id='l2h-135'></a></tt></td> |
| 104 | <td class="left" ><tt class="exception">IOError</tt></td> |
| 105 | <td class="center"></td></tr> |
| 106 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_ImportError<a id='l2h-136' xml:id='l2h-136'></a></tt></td> |
| 107 | <td class="left" ><tt class="exception">ImportError</tt></td> |
| 108 | <td class="center"></td></tr> |
| 109 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_IndexError<a id='l2h-137' xml:id='l2h-137'></a></tt></td> |
| 110 | <td class="left" ><tt class="exception">IndexError</tt></td> |
| 111 | <td class="center"></td></tr> |
| 112 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_KeyError<a id='l2h-138' xml:id='l2h-138'></a></tt></td> |
| 113 | <td class="left" ><tt class="exception">KeyError</tt></td> |
| 114 | <td class="center"></td></tr> |
| 115 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_KeyboardInterrupt<a id='l2h-139' xml:id='l2h-139'></a></tt></td> |
| 116 | <td class="left" ><tt class="exception">KeyboardInterrupt</tt></td> |
| 117 | <td class="center"></td></tr> |
| 118 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_MemoryError<a id='l2h-140' xml:id='l2h-140'></a></tt></td> |
| 119 | <td class="left" ><tt class="exception">MemoryError</tt></td> |
| 120 | <td class="center"></td></tr> |
| 121 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_NameError<a id='l2h-141' xml:id='l2h-141'></a></tt></td> |
| 122 | <td class="left" ><tt class="exception">NameError</tt></td> |
| 123 | <td class="center"></td></tr> |
| 124 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_NotImplementedError<a id='l2h-142' xml:id='l2h-142'></a></tt></td> |
| 125 | <td class="left" ><tt class="exception">NotImplementedError</tt></td> |
| 126 | <td class="center"></td></tr> |
| 127 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_OSError<a id='l2h-143' xml:id='l2h-143'></a></tt></td> |
| 128 | <td class="left" ><tt class="exception">OSError</tt></td> |
| 129 | <td class="center"></td></tr> |
| 130 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_OverflowError<a id='l2h-144' xml:id='l2h-144'></a></tt></td> |
| 131 | <td class="left" ><tt class="exception">OverflowError</tt></td> |
| 132 | <td class="center"></td></tr> |
| 133 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_ReferenceError<a id='l2h-145' xml:id='l2h-145'></a></tt></td> |
| 134 | <td class="left" ><tt class="exception">ReferenceError</tt></td> |
| 135 | <td class="center">(2)</td></tr> |
| 136 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_RuntimeError<a id='l2h-146' xml:id='l2h-146'></a></tt></td> |
| 137 | <td class="left" ><tt class="exception">RuntimeError</tt></td> |
| 138 | <td class="center"></td></tr> |
| 139 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_SyntaxError<a id='l2h-147' xml:id='l2h-147'></a></tt></td> |
| 140 | <td class="left" ><tt class="exception">SyntaxError</tt></td> |
| 141 | <td class="center"></td></tr> |
| 142 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_SystemError<a id='l2h-148' xml:id='l2h-148'></a></tt></td> |
| 143 | <td class="left" ><tt class="exception">SystemError</tt></td> |
| 144 | <td class="center"></td></tr> |
| 145 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_SystemExit<a id='l2h-149' xml:id='l2h-149'></a></tt></td> |
| 146 | <td class="left" ><tt class="exception">SystemExit</tt></td> |
| 147 | <td class="center"></td></tr> |
| 148 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_TypeError<a id='l2h-150' xml:id='l2h-150'></a></tt></td> |
| 149 | <td class="left" ><tt class="exception">TypeError</tt></td> |
| 150 | <td class="center"></td></tr> |
| 151 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_ValueError<a id='l2h-151' xml:id='l2h-151'></a></tt></td> |
| 152 | <td class="left" ><tt class="exception">ValueError</tt></td> |
| 153 | <td class="center"></td></tr> |
| 154 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_WindowsError<a id='l2h-152' xml:id='l2h-152'></a></tt></td> |
| 155 | <td class="left" ><tt class="exception">WindowsError</tt></td> |
| 156 | <td class="center">(3)</td></tr> |
| 157 | <tr><td class="left" valign="baseline"><tt class="cdata">PyExc_ZeroDivisionError<a id='l2h-153' xml:id='l2h-153'></a></tt></td> |
| 158 | <td class="left" ><tt class="exception">ZeroDivisionError</tt></td> |
| 159 | <td class="center"></td></tr></tbody> |
| 160 | </table></div> |
| 161 | |
| 162 | <P> |
| 163 | Notes: |
| 164 | <DL> |
| 165 | <DT><STRONG>(1)</STRONG></DT> |
| 166 | <DD>This is a base class for other standard exceptions. |
| 167 | |
| 168 | <P> |
| 169 | </DD> |
| 170 | <DT><STRONG>(2)</STRONG></DT> |
| 171 | <DD>This is the same as <tt class="exception">weakref.ReferenceError</tt>. |
| 172 | |
| 173 | <P> |
| 174 | </DD> |
| 175 | <DT><STRONG>(3)</STRONG></DT> |
| 176 | <DD>Only defined on Windows; protect code that uses this by testing that |
| 177 | the preprocessor macro <code>MS_WINDOWS</code> is defined. |
| 178 | </DD> |
| 179 | </DL> |
| 180 | |
| 181 | <P> |
| 182 | |
| 183 | <DIV CLASS="navigation"> |
| 184 | <div class='online-navigation'> |
| 185 | <p></p><hr /> |
| 186 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 187 | <tr> |
| 188 | <td class='online-navigation'><a rel="prev" title="4. Exception Handling" |
| 189 | href="exceptionHandling.html"><img src='../icons/previous.png' |
| 190 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 191 | <td class='online-navigation'><a rel="parent" title="4. Exception Handling" |
| 192 | href="exceptionHandling.html"><img src='../icons/up.png' |
| 193 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 194 | <td class='online-navigation'><a rel="next" title="4.2 Deprecation of String" |
| 195 | href="node15.html"><img src='../icons/next.png' |
| 196 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 197 | <td align="center" width="100%">Python/C API Reference Manual</td> |
| 198 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 199 | href="contents.html"><img src='../icons/contents.png' |
| 200 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 201 | <td class='online-navigation'><img src='../icons/blank.png' |
| 202 | border='0' height='32' alt='' width='32' /></td> |
| 203 | <td class='online-navigation'><a rel="index" title="Index" |
| 204 | href="genindex.html"><img src='../icons/index.png' |
| 205 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 206 | </tr></table> |
| 207 | <div class='online-navigation'> |
| 208 | <b class="navlabel">Previous:</b> |
| 209 | <a class="sectref" rel="prev" href="exceptionHandling.html">4. Exception Handling</A> |
| 210 | <b class="navlabel">Up:</b> |
| 211 | <a class="sectref" rel="parent" href="exceptionHandling.html">4. Exception Handling</A> |
| 212 | <b class="navlabel">Next:</b> |
| 213 | <a class="sectref" rel="next" href="node15.html">4.2 Deprecation of String</A> |
| 214 | </div> |
| 215 | </div> |
| 216 | <hr /> |
| 217 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 218 | </DIV> |
| 219 | <!--End of Navigation Panel--> |
| 220 | <ADDRESS> |
| 221 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 222 | </ADDRESS> |
| 223 | </BODY> |
| 224 | </HTML> |