Author: mtredinnick
Date: 2007-10-21 13:15:01 -0500 (Sun, 21 Oct 2007)
New Revision: 6585
Modified:
django/trunk/django/views/debug.py
Log:
Fixed #5712 -- Added more robustness to source code display in the debug view.
Our behaviour is a bit more PEP 263 compliant now, too. Thanks, Thomas
G?\195?\188ttler.
Modified: django/trunk/django/views/debug.py
===================================================================
--- django/trunk/django/views/debug.py 2007-10-21 17:51:06 UTC (rev 6584)
+++ django/trunk/django/views/debug.py 2007-10-21 18:15:01 UTC (rev 6585)
@@ -201,16 +201,15 @@
if source is None:
return None, [], None, []
- encoding=None
+ encoding = 'ascii'
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/)
+ # File coding may be specified. 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]
+ source = [unicode(sline, encoding, 'replace') for sline in source]
lower_bound = max(0, lineno - context_lines)
upper_bound = lineno + context_lines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---