<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Module: core.ultratb — IPython 2.3.0 documentation</title> <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '2.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="top" title="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: core.usage" href="IPython.core.usage.html" /> <link rel="prev" title="Module: core.splitinput" href="IPython.core.splitinput.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.usage.html" title="Module: core.usage" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.core.splitinput.html" title="Module: core.splitinput" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">core.ultratb</span></tt></a><ul> <li><a class="reference internal" href="#color-schemes">Color schemes</a></li> <li><a class="reference internal" href="#classes">7 Classes</a></li> <li><a class="reference internal" href="#functions">4 Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.core.splitinput.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.splitinput</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.core.usage.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.usage</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.core.ultratb.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.core.ultratb"> <span id="module-core-ultratb"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.ultratb</span></tt><a class="headerlink" href="#module-IPython.core.ultratb" title="Permalink to this headline">¶</a></h1> <p>Verbose and colourful traceback formatting.</p> <p><strong>ColorTB</strong></p> <p>I’ve always found it a bit hard to visually parse tracebacks in Python. The ColorTB class is a solution to that problem. It colors the different parts of a traceback in a manner similar to what you would expect from a syntax-highlighting text editor.</p> <p>Installation instructions for ColorTB:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span><span class="nn">ultratb</span> <span class="n">sys</span><span class="o">.</span><span class="n">excepthook</span> <span class="o">=</span> <span class="n">ultratb</span><span class="o">.</span><span class="n">ColorTB</span><span class="p">()</span> </pre></div> </div> <p><strong>VerboseTB</strong></p> <p>I’ve also included a port of Ka-Ping Yee’s “cgitb.py” that produces all kinds of useful info when a traceback occurs. Ping originally had it spit out HTML and intended it for CGI programmers, but why should they have all the fun? I altered it to spit out colored text to the terminal. It’s a bit overwhelming, but kind of neat, and maybe useful for long-running programs that you believe are bug-free. If a crash <em>does</em> occur in that type of program you want details. Give it a shot–you’ll love it or you’ll hate it.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>The Verbose mode prints the variables currently visible where the exception happened (shortening their strings if too long). This can potentially be very slow, if you happen to have a huge data structure whose string representation is complex to compute. Your computer may appear to freeze for a while with cpu usage at 100%. If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than once).</p> <p class="last">If you encounter this kind of situation often, you may want to use the Verbose_novars mode instead of the regular Verbose, which avoids formatting variables (but otherwise includes the information and context given by Verbose).</p> </div> <p>Installation instructions for ColorTB:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span><span class="nn">ultratb</span> <span class="n">sys</span><span class="o">.</span><span class="n">excepthook</span> <span class="o">=</span> <span class="n">ultratb</span><span class="o">.</span><span class="n">VerboseTB</span><span class="p">()</span> </pre></div> </div> <p>Note: Much of the code in this module was lifted verbatim from the standard library module ‘traceback.py’ and Ka-Ping Yee’s ‘cgitb.py’.</p> <div class="section" id="color-schemes"> <h2>Color schemes<a class="headerlink" href="#color-schemes" title="Permalink to this headline">¶</a></h2> <p>The colors are defined in the class TBTools through the use of the ColorSchemeTable class. Currently the following exist:</p> <blockquote> <div><ul class="simple"> <li>NoColor: allows all of this module to be used in any terminal (the color escapes are just dummy blank strings).</li> <li>Linux: is meant to look good in a terminal like the Linux console (black or very dark background).</li> <li>LightBG: similar to Linux but swaps dark/light colors to be more readable in light background terminals.</li> </ul> </div></blockquote> <p>You can implement other color schemes easily, the syntax is fairly self-explanatory. Please send back new schemes you develop to the author for possible inclusion in future releases.</p> <p>Inheritance diagram:</p> <p class="graphviz"> digraph inheritance03e43aa880 { rankdir=LR; size="8.0, 12.0"; "core.ultratb.AutoFormattedTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.AutoFormattedTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="A traceback printer which can be called on the fly.",height=0.25,shape=box,fontsize=10]; "core.ultratb.FormattedTB" -> "core.ultratb.AutoFormattedTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.ColorTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.ColorTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Shorthand to initialize a FormattedTB in Linux colors mode.",height=0.25,shape=box,fontsize=10]; "core.ultratb.FormattedTB" -> "core.ultratb.ColorTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.FormattedTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.FormattedTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Subclass ListTB but allow calling with a traceback.",height=0.25,shape=box,fontsize=10]; "core.ultratb.VerboseTB" -> "core.ultratb.FormattedTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.ListTB" -> "core.ultratb.FormattedTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.ListTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.ListTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Print traceback information from a traceback list, with optional color.",height=0.25,shape=box,fontsize=10]; "core.ultratb.TBTools" -> "core.ultratb.ListTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.SyntaxTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.SyntaxTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Extension which holds some state: the last exception value",height=0.25,shape=box,fontsize=10]; "core.ultratb.ListTB" -> "core.ultratb.SyntaxTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; "core.ultratb.TBTools" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.TBTools",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Basic tools used by all traceback printer classes.",height=0.25,shape=box,fontsize=10]; "core.ultratb.VerboseTB" [style="setlinewidth(0.5)",URL="#IPython.core.ultratb.VerboseTB",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="A port of Ka-Ping Yee's cgitb.py module that outputs color text instead",height=0.25,shape=box,fontsize=10]; "core.ultratb.TBTools" -> "core.ultratb.VerboseTB" [arrowsize=0.5,style="setlinewidth(0.5)"]; } </p> </div> <div class="section" id="classes"> <h2>7 Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.core.ultratb.TBTools"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">TBTools</tt><big>(</big><em>color_scheme=u'NoColor'</em>, <em>call_pdb=False</em>, <em>ostream=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference external" href="http://docs.python.org/2/library/functions.html#object" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></a></p> <p>Basic tools used by all traceback printer classes.</p> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_scheme=u'NoColor'</em>, <em>call_pdb=False</em>, <em>ostream=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.color_toggle"> <tt class="descname">color_toggle</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.color_toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Toggle between the currently active color scheme and NoColor.</p> </dd></dl> <dl class="attribute"> <dt id="IPython.core.ultratb.TBTools.ostream"> <tt class="descname">ostream</tt><a class="headerlink" href="#IPython.core.ultratb.TBTools.ostream" title="Permalink to this definition">¶</a></dt> <dd><p>Output stream that exceptions are written to.</p> <p>Valid values are:</p> <ul class="simple"> <li>None: the default, which means that IPython will dynamically resolve to io.stdout. This ensures compatibility with most tools, including Windows (where plain stdout doesn’t recognize ANSI escapes).</li> <li>Any object with ‘write’ and ‘flush’ attributes.</li> </ul> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.set_colors"> <tt class="descname">set_colors</tt><big>(</big><em>*args</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.set_colors" title="Permalink to this definition">¶</a></dt> <dd><p>Shorthand access to the color table scheme selector method.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.stb2text"> <tt class="descname">stb2text</tt><big>(</big><em>stb</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.stb2text" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a structured traceback (a list) to a string.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.structured_traceback"> <tt class="descname">structured_traceback</tt><big>(</big><em>etype</em>, <em>evalue</em>, <em>tb</em>, <em>tb_offset=None</em>, <em>context=5</em>, <em>mode=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.structured_traceback" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of traceback frames.</p> <p>Must be implemented by each class.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.TBTools.text"> <tt class="descname">text</tt><big>(</big><em>etype</em>, <em>value</em>, <em>tb</em>, <em>tb_offset=None</em>, <em>context=5</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.TBTools.text" title="Permalink to this definition">¶</a></dt> <dd><p>Return formatted traceback.</p> <p>Subclasses may override this if they add extra arguments.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.ListTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">ListTB</tt><big>(</big><em>color_scheme=u'NoColor'</em>, <em>call_pdb=False</em>, <em>ostream=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ListTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.TBTools" title="IPython.core.ultratb.TBTools"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.TBTools</span></tt></a></p> <p>Print traceback information from a traceback list, with optional color.</p> <p>Calling requires 3 arguments: (etype, evalue, elist) as would be obtained by:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">etype</span><span class="p">,</span> <span class="n">evalue</span><span class="p">,</span> <span class="n">tb</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()</span> <span class="k">if</span> <span class="n">tb</span><span class="p">:</span> <span class="n">elist</span> <span class="o">=</span> <span class="n">traceback</span><span class="o">.</span><span class="n">extract_tb</span><span class="p">(</span><span class="n">tb</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="n">elist</span> <span class="o">=</span> <span class="bp">None</span> </pre></div> </div> <p>It can thus be used by programs which need to process the traceback before printing (such as console replacements based on the code module from the standard library).</p> <p>Because they are meant to be called without a full traceback (only a list), instances of this class can’t call the interactive pdb debugger.</p> <dl class="method"> <dt id="IPython.core.ultratb.ListTB.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_scheme=u'NoColor'</em>, <em>call_pdb=False</em>, <em>ostream=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ListTB.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.ListTB.get_exception_only"> <tt class="descname">get_exception_only</tt><big>(</big><em>etype</em>, <em>value</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ListTB.get_exception_only" title="Permalink to this definition">¶</a></dt> <dd><p>Only print the exception type and message, without a traceback.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>etype</strong> : exception type</p> <p class="last"><strong>value</strong> : exception value</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.ListTB.show_exception_only"> <tt class="descname">show_exception_only</tt><big>(</big><em>etype</em>, <em>evalue</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ListTB.show_exception_only" title="Permalink to this definition">¶</a></dt> <dd><p>Only print the exception type and message, without a traceback.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>etype</strong> : exception type</p> <p class="last"><strong>value</strong> : exception value</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.ListTB.structured_traceback"> <tt class="descname">structured_traceback</tt><big>(</big><em>etype</em>, <em>value</em>, <em>elist</em>, <em>tb_offset=None</em>, <em>context=5</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ListTB.structured_traceback" title="Permalink to this definition">¶</a></dt> <dd><p>Return a color formatted string with the traceback info.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>etype</strong> : exception type</p> <blockquote> <div><p>Type of the exception raised.</p> </div></blockquote> <p><strong>value</strong> : object</p> <blockquote> <div><p>Data stored in the exception</p> </div></blockquote> <p><strong>elist</strong> : list</p> <blockquote> <div><p>List of frames, see class docstring for details.</p> </div></blockquote> <p><strong>tb_offset</strong> : int, optional</p> <blockquote> <div><p>Number of frames in the traceback to skip. If not given, the instance value is used (set in constructor).</p> </div></blockquote> <p><strong>context</strong> : int, optional</p> <blockquote> <div><p>Number of lines of context information to print.</p> </div></blockquote> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">String with formatted exception.</p> </td> </tr> </tbody> </table> </dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.VerboseTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">VerboseTB</tt><big>(</big><em>color_scheme=u'Linux'</em>, <em>call_pdb=False</em>, <em>ostream=None</em>, <em>tb_offset=0</em>, <em>long_header=False</em>, <em>include_vars=True</em>, <em>check_cache=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.VerboseTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.TBTools" title="IPython.core.ultratb.TBTools"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.TBTools</span></tt></a></p> <p>A port of Ka-Ping Yee’s cgitb.py module that outputs color text instead of HTML. Requires inspect and pydoc. Crazy, man.</p> <p>Modified version which optionally strips the topmost entries from the traceback, to be used with alternate interpreters (because their own code would appear in the traceback).</p> <dl class="method"> <dt id="IPython.core.ultratb.VerboseTB.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_scheme=u'Linux'</em>, <em>call_pdb=False</em>, <em>ostream=None</em>, <em>tb_offset=0</em>, <em>long_header=False</em>, <em>include_vars=True</em>, <em>check_cache=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.VerboseTB.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Specify traceback offset, headers and color scheme.</p> <p>Define how many frames to drop from the tracebacks. Calling it with tb_offset=1 allows use of this handler in interpreters which will have their own code at the top of the traceback (VerboseTB will first remove that frame before printing the traceback info).</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.VerboseTB.debugger"> <tt class="descname">debugger</tt><big>(</big><em>force=False</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.VerboseTB.debugger" title="Permalink to this definition">¶</a></dt> <dd><p>Call up the pdb debugger if desired, always clean up the tb reference.</p> <p>Keywords:</p> <blockquote> <div><ul class="simple"> <li>force(False): by default, this routine checks the instance call_pdb flag and does not actually invoke the debugger if the flag is false. The ‘force’ option forces the debugger to activate even if the flag is false.</li> </ul> </div></blockquote> <p>If the call_pdb flag is set, the pdb interactive debugger is invoked. In all cases, the self.tb reference to the current traceback is deleted to prevent lingering references which hamper memory management.</p> <p>Note that each call to pdb() does an ‘import readline’, so if your app requires a special setup for the readline completers, you’ll have to fix that by hand after invoking the exception handler.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.VerboseTB.structured_traceback"> <tt class="descname">structured_traceback</tt><big>(</big><em>etype</em>, <em>evalue</em>, <em>etb</em>, <em>tb_offset=None</em>, <em>context=5</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.VerboseTB.structured_traceback" title="Permalink to this definition">¶</a></dt> <dd><p>Return a nice text document describing the traceback.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.FormattedTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">FormattedTB</tt><big>(</big><em>mode=u'Plain'</em>, <em>color_scheme=u'Linux'</em>, <em>call_pdb=False</em>, <em>ostream=None</em>, <em>tb_offset=0</em>, <em>long_header=False</em>, <em>include_vars=False</em>, <em>check_cache=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.FormattedTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.VerboseTB" title="IPython.core.ultratb.VerboseTB"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.VerboseTB</span></tt></a>, <a class="reference internal" href="#IPython.core.ultratb.ListTB" title="IPython.core.ultratb.ListTB"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.ListTB</span></tt></a></p> <p>Subclass ListTB but allow calling with a traceback.</p> <p>It can thus be used as a sys.excepthook for Python > 2.1.</p> <p>Also adds ‘Context’ and ‘Verbose’ modes, not available in ListTB.</p> <p>Allows a tb_offset to be specified. This is useful for situations where one needs to remove a number of topmost frames from the traceback (such as occurs with python programs that themselves execute other python code, like Python shells).</p> <dl class="method"> <dt id="IPython.core.ultratb.FormattedTB.__init__"> <tt class="descname">__init__</tt><big>(</big><em>mode=u'Plain'</em>, <em>color_scheme=u'Linux'</em>, <em>call_pdb=False</em>, <em>ostream=None</em>, <em>tb_offset=0</em>, <em>long_header=False</em>, <em>include_vars=False</em>, <em>check_cache=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.FormattedTB.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.FormattedTB.set_mode"> <tt class="descname">set_mode</tt><big>(</big><em>mode=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.FormattedTB.set_mode" title="Permalink to this definition">¶</a></dt> <dd><p>Switch to the desired mode.</p> <p>If mode is not specified, cycles through the available modes.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.FormattedTB.stb2text"> <tt class="descname">stb2text</tt><big>(</big><em>stb</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.FormattedTB.stb2text" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a structured traceback (a list) to a string.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.AutoFormattedTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">AutoFormattedTB</tt><big>(</big><em>mode=u'Plain'</em>, <em>color_scheme=u'Linux'</em>, <em>call_pdb=False</em>, <em>ostream=None</em>, <em>tb_offset=0</em>, <em>long_header=False</em>, <em>include_vars=False</em>, <em>check_cache=None</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.AutoFormattedTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.FormattedTB" title="IPython.core.ultratb.FormattedTB"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.FormattedTB</span></tt></a></p> <p>A traceback printer which can be called on the fly.</p> <p>It will find out about exceptions by itself.</p> <p>A brief example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">AutoTB</span> <span class="o">=</span> <span class="n">AutoFormattedTB</span><span class="p">(</span><span class="n">mode</span> <span class="o">=</span> <span class="s">'Verbose'</span><span class="p">,</span><span class="n">color_scheme</span><span class="o">=</span><span class="s">'Linux'</span><span class="p">)</span> <span class="k">try</span><span class="p">:</span> <span class="o">...</span> <span class="k">except</span><span class="p">:</span> <span class="n">AutoTB</span><span class="p">()</span> <span class="c"># or AutoTB(out=logfile) where logfile is an open file object</span> </pre></div> </div> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.ColorTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">ColorTB</tt><big>(</big><em>color_scheme=u'Linux'</em>, <em>call_pdb=0</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ColorTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.FormattedTB" title="IPython.core.ultratb.FormattedTB"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.FormattedTB</span></tt></a></p> <p>Shorthand to initialize a FormattedTB in Linux colors mode.</p> <dl class="method"> <dt id="IPython.core.ultratb.ColorTB.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_scheme=u'Linux'</em>, <em>call_pdb=0</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.ColorTB.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.core.ultratb.SyntaxTB"> <em class="property">class </em><tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">SyntaxTB</tt><big>(</big><em>color_scheme=u'NoColor'</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.SyntaxTB" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#IPython.core.ultratb.ListTB" title="IPython.core.ultratb.ListTB"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.ultratb.ListTB</span></tt></a></p> <p>Extension which holds some state: the last exception value</p> <dl class="method"> <dt id="IPython.core.ultratb.SyntaxTB.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_scheme=u'NoColor'</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.SyntaxTB.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.SyntaxTB.clear_err_state"> <tt class="descname">clear_err_state</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.ultratb.SyntaxTB.clear_err_state" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current error state and clear it</p> </dd></dl> <dl class="method"> <dt id="IPython.core.ultratb.SyntaxTB.stb2text"> <tt class="descname">stb2text</tt><big>(</big><em>stb</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.SyntaxTB.stb2text" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a structured traceback (a list) to a string.</p> </dd></dl> </dd></dl> </div> <div class="section" id="functions"> <h2>4 Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.core.ultratb.inspect_error"> <tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">inspect_error</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.ultratb.inspect_error" title="Permalink to this definition">¶</a></dt> <dd><p>Print a message about internal inspect errors.</p> <p>These are unfortunately quite common.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.ultratb.findsource"> <tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">findsource</tt><big>(</big><em>object</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.findsource" title="Permalink to this definition">¶</a></dt> <dd><p>Return the entire source file and starting line number for an object.</p> <p>The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.</p> <p>FIXED version with which we monkeypatch the stdlib to work around a bug.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.ultratb.with_patch_inspect"> <tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">with_patch_inspect</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.with_patch_inspect" title="Permalink to this definition">¶</a></dt> <dd><p>decorator for monkeypatching inspect.findsource</p> </dd></dl> <dl class="function"> <dt id="IPython.core.ultratb.fix_frame_records_filenames"> <tt class="descclassname">IPython.core.ultratb.</tt><tt class="descname">fix_frame_records_filenames</tt><big>(</big><em>records</em><big>)</big><a class="headerlink" href="#IPython.core.ultratb.fix_frame_records_filenames" title="Permalink to this definition">¶</a></dt> <dd><p>Try to fix the filenames in each record from inspect.getinnerframes().</p> <p>Particularly, modules loaded from within zip files have useless filenames attached to their code object, and inspect.getinnerframes() just uses it.</p> </dd></dl> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.usage.html" title="Module: core.usage" >next</a> |</li> <li class="right" > <a href="IPython.core.splitinput.html" title="Module: core.splitinput" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Jul 14, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>