Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/cgitb.py

    r2 r388  
    20203-item tuple (etype, evalue, etb) just like the value of sys.exc_info().
    2121The default handler displays output as HTML.
     22
    2223"""
    23 
    24 __author__ = 'Ka-Ping Yee'
    25 
    26 __version__ = '$Revision: 55348 $'
    27 
     24import inspect
     25import keyword
     26import linecache
     27import os
     28import pydoc
    2829import sys
     30import tempfile
     31import time
     32import tokenize
     33import traceback
     34import types
    2935
    3036def reset():
     
    7581def scanvars(reader, frame, locals):
    7682    """Scan one logical line of Python and look up values of variables used."""
    77     import tokenize, keyword
    7883    vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
    7984    for ttype, token, start, end, line in tokenize.generate_tokens(reader):
     
    95100    return vars
    96101
    97 def html((etype, evalue, etb), context=5):
     102def html(einfo, context=5):
    98103    """Return a nice HTML document describing a given traceback."""
    99     import os, types, time, traceback, linecache, inspect, pydoc
    100 
     104    etype, evalue, etb = einfo
    101105    if type(etype) is types.ClassType:
    102106        etype = etype.__name__
     
    139143            for line in lines:
    140144                num = small(' ' * (5-len(str(i))) + str(i)) + ' '
    141                 line = '<tt>%s%s</tt>' % (num, pydoc.html.preformat(line))
    142145                if i in highlight:
     146                    line = '<tt>=&gt;%s%s</tt>' % (num, pydoc.html.preformat(line))
    143147                    rows.append('<tr><td bgcolor="#ffccee">%s</td></tr>' % line)
    144148                else:
     149                    line = '<tt>&nbsp;&nbsp;%s%s</tt>' % (num, pydoc.html.preformat(line))
    145150                    rows.append('<tr><td>%s</td></tr>' % grey(line))
    146151                i += 1
     
    174179            exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
    175180
    176     import traceback
    177181    return head + ''.join(frames) + ''.join(exception) + '''
    178182
     
    187191          ''.join(traceback.format_exception(etype, evalue, etb)))
    188192
    189 def text((etype, evalue, etb), context=5):
     193def text(einfo, context=5):
    190194    """Return a plain text document describing a given traceback."""
    191     import os, types, time, traceback, linecache, inspect, pydoc
    192 
     195    etype, evalue, etb = einfo
    193196    if type(etype) is types.ClassType:
    194197        etype = etype.__name__
     
    246249            exception.append('\n%s%s = %s' % (" "*4, name, value))
    247250
    248     import traceback
    249251    return head + ''.join(frames) + ''.join(exception) + '''
    250252
     
    279281            doc = formatter(info, self.context)
    280282        except:                         # just in case something goes wrong
    281             import traceback
    282283            doc = ''.join(traceback.format_exception(*info))
    283284            plain = True
     
    293294
    294295        if self.logdir is not None:
    295             import os, tempfile
    296296            suffix = ['.txt', '.html'][self.format=="html"]
    297297            (fd, path) = tempfile.mkstemp(suffix=suffix, dir=self.logdir)
     298
    298299            try:
    299300                file = os.fdopen(fd, 'w')
    300301                file.write(doc)
    301302                file.close()
    302                 msg = '<p> %s contains the description of this error.' % path
     303                msg = '%s contains the description of this error.' % path
    303304            except:
    304                 msg = '<p> Tried to save traceback to %s, but failed.' % path
    305             self.file.write(msg + '\n')
     305                msg = 'Tried to save traceback to %s, but failed.' % path
     306
     307            if self.format == 'html':
     308                self.file.write('<p>%s</p>\n' % msg)
     309            else:
     310                self.file.write(msg + '\n')
    306311        try:
    307312            self.file.flush()
Note: See TracChangeset for help on using the changeset viewer.