Django

Code

Changeset 5193

Show
Ignore:
Timestamp:
05/11/07 09:49:43 (1 year ago)
Author:
mtredinnick
Message:

unicode: Fixed #4249 -- Decode source files correctly in the debug view.
Thanks, Thomas Güttler.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/AUTHORS

    r5185 r5193  
    108108    Owen Griffiths 
    109109    Espen Grindhaug <http://grindhaug.org/> 
     110    Thomas GÃŒttler <hv@tbz-pariv.de> 
    110111    Brian Harring <ferringb@gmail.com> 
    111112    Brant Harris 
  • django/branches/unicode/django/views/debug.py

    r5054 r5193  
    188188    if source is None: 
    189189        return None, [], None, [] 
     190 
     191    encoding=None 
     192    for line in source[:2]: 
     193        # File coding may be specified (and may not be UTF-8). Match 
     194        # pattern from PEP-263 (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] 
    190201 
    191202    lower_bound = max(0, lineno - context_lines)