Ticket #20534: django20534_make_debug_more_resilient.patch

File django20534_make_debug_more_resilient.patch, 1.0 KB (added by Walter Doekes, 11 years ago)
  • django/views/debug.py

    old new class ExceptionReporter(object):  
    244244        frames = self.get_traceback_frames()
    245245        for i, frame in enumerate(frames):
    246246            if 'vars' in frame:
    247                 frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']]
     247                vars = []
     248                for k, v in frame['vars']:
     249                    v = pprint(v)
     250                    # The force_escape filter assume unicode, make sure that works
     251                    if isinstance(v, str):
     252                        v = v.decode('utf-8', 'replace')  # don't choke on non-utf-8 input
     253                    # You may be looking at large blobs of data, trim it
     254                    if len(v) > 4096:
     255                        v = u'%s... <trimmed %d bytes string>' % (v[0:4096], len(v))
     256                    vars.append((k, force_escape(v)))
     257                frame['vars'] = vars
    248258            frames[i] = frame
    249259
    250260        unicode_hint = ''
Back to Top