Ticket #5712: views_debug_replace_invalid_chars.diff
File views_debug_replace_invalid_chars.diff, 834 bytes (added by , 17 years ago) |
---|
-
django/views/debug.py
201 206 if source is None: 202 207 return None, [], None, [] 203 208 204 encoding= None209 encoding="ascii" 205 210 for line in source[:2]: 206 211 # File coding may be specified (and may not be UTF-8). Match 207 212 # pattern from PEP-263 (http://www.python.org/dev/peps/pep-0263/) … … 209 214 if match: 210 215 encoding = match.group(1) 211 216 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 215 219 lower_bound = max(0, lineno - context_lines) 216 220 upper_bound = lineno + context_lines 217 221