#13958: There is an error, when a source file with backslash-r returns is
interpreted by the Python error report page.
-------------------------------------------+-------------------------------
               Reporter:  petrvanblokland  |          Owner:  nessita
                   Type:  Uncategorized    |         Status:  reopened
              Milestone:                   |      Component:  Uncategorized
                Version:  1.2              |       Severity:  Normal
             Resolution:                   |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  1
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+-------------------------------
Changes (by fredrik.kers@…):

 * status:  closed => reopened
 * severity:   => Normal
 * resolution:  invalid =>
 * easy:   => 0
 * has_patch:  0 => 1
 * ui_ux:   => 0
 * type:   => Uncategorized


Comment:

 django.views.debug._get_lines_from_file uses readlines to split the lines
 of a file. This functions does not support the old Macintosh line break
 (\r) which is a valid line break in python code
 (http://docs.python.org/reference/lexical_analysis.html#physical-lines).
 So when an exception occurs in a file with Macintosh line break, the
 get_lines_from_file method will get an exception on the line
 {{{
 context_line = source[lineno].strip('\n')
 }}}
 since the source list will only contain one line with alot of '\r'.

 This can be fixed by replacing the line
 {{{
 source = f.readlines()
 }}}
 with
 {{{
 source = f.read().splitlines()
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13958#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
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.

Reply via email to