mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
unicode: Fixed #4249 -- Decode source files correctly in the debug view.
Thanks, Thomas Güttler. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
56db7a6078
commit
7225efba50
1
AUTHORS
1
AUTHORS
@ -107,6 +107,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Simon Greenhill <dev@simon.net.nz>
|
||||
Owen Griffiths
|
||||
Espen Grindhaug <http://grindhaug.org/>
|
||||
Thomas Güttler <hv@tbz-pariv.de>
|
||||
Brian Harring <ferringb@gmail.com>
|
||||
Brant Harris
|
||||
Hawkeye
|
||||
|
@ -188,6 +188,17 @@ def _get_lines_from_file(filename, lineno, context_lines, loader=None, module_na
|
||||
if source is None:
|
||||
return None, [], None, []
|
||||
|
||||
encoding=None
|
||||
for line in source[:2]:
|
||||
# File coding may be specified (and may not be UTF-8). Match
|
||||
# pattern from PEP-263 (http://www.python.org/dev/peps/pep-0263/)
|
||||
match = re.search(r'coding[:=]\s*([-\w.]+)', line)
|
||||
if match:
|
||||
encoding = match.group(1)
|
||||
break
|
||||
if encoding:
|
||||
source = [unicode(sline, encoding) for sline in source]
|
||||
|
||||
lower_bound = max(0, lineno - context_lines)
|
||||
upper_bound = lineno + context_lines
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user