#19357: Unicode errors when Django is installed under a non-ASCII path
---------------------------------+-------------------------------------
     Reporter:  kujiu            |                    Owner:  aaugustin
         Type:  Bug              |                   Status:  new
    Component:  Python 2         |                  Version:  master
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+-------------------------------------

Comment (by aaugustin):

 Here's another random example (file `/tmp/café.txt` exists on disk):

 Django 1.4.2
 {{{
 >>> from django.http import HttpRequest
 >>> from django.views.static import serve
 >>> serve(HttpRequest(), 'café.txt', '/tmp')
 <django.http.HttpResponse object at 0x104ebf310>
 }}}

 master
 {{{
 >>> from django.http import HttpRequest
 >>> from django.views.static import serve
 >>> serve(HttpRequest(), 'café.txt', '/tmp')
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/Users/myk/Documents/dev/django/django/views/static.py", line 38,
 in serve
     path = path.lstrip('/')
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3:
 ordinal not in range(128)
 }}}
 (This happens because unicode_literals is enabled => `'/'` is unicode =>
 `path.lstrip('/')` attempts to convert `path` to unicode.)

 We both spent hours working on this, and none of our patches fixes that
 regression!

 ----

 From the users' point of view, it's the amount of breakage between 1.4 and
 1.5 that matters, more than the amount of changes we have to do between
 now and 1.5. The real question is — how do we minimize the number of such
 regressions in modules where unicode_literals is enabled?

 I don't have an answer. My instincts tell me that switching all filesystem
 path handling to unicode is risky — all the more since it happened by
 accident rather than for a good reason, and since no one anticipated the
 consequences — but that's nowhere near a scientific argument!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19357#comment:13>
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to