#18430: CachedFilesMixin crashed when CSS files contains non-ascii utf-8 
character
-------------------------------------+--------------------
     Reporter:  brantyoung           |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  contrib.staticfiles  |    Version:  1.4
     Severity:  Release blocker      |   Keywords:
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  1                    |      UI/UX:  0
-------------------------------------+--------------------
 Traceback (most recent call last):
 {{{
 ...
 ...
   File ".../ENV/local/lib/python2.7/site-
 packages/django/contrib/staticfiles/management/commands/collectstatic.py",
 line 120, in collect
     for original_path, processed_path, processed in processor:
   File ".../ENV/local/lib/python2.7/site-
 packages/django/contrib/staticfiles/storage.py", line 226, in post_process
     content = pattern.sub(converter, content)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 366:
 ordinal not in range(128)
 }}}

 Reproduce:

 # save a css file that contains non-ascii utf-8 character (ie Chinese
 character):
 {{{
 .icon-link:before { content: "错"; }
 }}}
 # set ``STATICFILES_STORAGE`` to any storage class that will involve
 CachedFilesMixin mixin
 # run ``manage.py collectstatic``

 Howto fix:

 I relace following code:

 {{{
 content = original_file.read().decode
 }}}

 to:

 {{{
 content = original_file.read().decode('utf-8')
 }}}

 just worked as expected.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18430>
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 this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to