Ticket #5712: views_debug_replace_invalid_chars.diff

File views_debug_replace_invalid_chars.diff, 834 bytes (added by Thomas Güttler <hv@…>, 17 years ago)
  • django/views/debug.py

     
    201206    if source is None:
    202207        return None, [], None, []
    203208
    204     encoding=None
     209    encoding="ascii"
    205210    for line in source[:2]:
    206211        # File coding may be specified (and may not be UTF-8). Match
    207212        # pattern from PEP-263 (http://www.python.org/dev/peps/pep-0263/)
     
    209214        if match:
    210215            encoding = match.group(1)
    211216            break
    212     if encoding:
    213         source = [unicode(sline, encoding) for sline in source]
    214 
     217    source = [unicode(sline, encoding, "replace") for sline in source]
     218       
    215219    lower_bound = max(0, lineno - context_lines)
    216220    upper_bound = lineno + context_lines
    217221
Back to Top