Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Decoded the parsed source file encoding in debug view

  • Loading branch information...
commit 4797ad80da57f3f8a7c029008f3e937240cf23e6 1 parent 88cc002
Claude Paroz authored October 08, 2012
2  django/views/debug.py
@@ -360,7 +360,7 @@ def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, mod
360 360
             # (http://www.python.org/dev/peps/pep-0263/)
361 361
             match = re.search(br'coding[:=]\s*([-\w.]+)', line)
362 362
             if match:
363  
-                encoding = match.group(1)
  363
+                encoding = match.group(1).decode('ascii')
364 364
                 break
365 365
         source = [six.text_type(sline, encoding, 'replace') for sline in source]
366 366
 
3  tests/regressiontests/views/tests/debug.py
... ...
@@ -1,3 +1,6 @@
  1
+# -*- coding: utf-8 -*-
  2
+# This coding header is significant for tests, as the debug view is parsing
  3
+# files to search for such a header to decode the source file content
1 4
 from __future__ import absolute_import, unicode_literals
2 5
 
3 6
 import inspect

0 notes on commit 4797ad8

Please sign in to comment.
Something went wrong with that request. Please try again.