Ticket #4249: views_debug_py.diff

File views_debug_py.diff, 757 bytes (added by Thomas Güttler <hv@…>, 18 years ago)
  • django/branches/unicode/django/views/debug.py

    old new  
    188188    if source is None:
    189189        return None, [], None, []
    190190
     191    encoding=None
     192    for line in source[0:min(len(source), 2)]:
     193        # Convert lines to unicode.
     194        # See: http://www.python.org/dev/peps/pep-0263/
     195        match = re.search(r'coding[:=]\s*([-\w.]+)', line)
     196        if match:
     197            encoding = match.group(1)
     198            break
     199    if encoding:
     200        source = [unicode(sline, encoding) for sline in source]
     201       
    191202    lower_bound = max(0, lineno - context_lines)
    192203    upper_bound = lineno + context_lines
    193204
Back to Top