#19367: ContentFile fails to save with filesystem storage when initialized with
unicode string
-------------------------------------+-------------------------------------
     Reporter:  void                 |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  File                 |                  Version:  master
  uploads/storage                    |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by daphshez):

 * status:  closed => new
 * resolution:  fixed =>


Comment:

 I just ran the tests on the development code and had the test fail.

 This is a Windows machine with default locale 'cp1255'.

 I think the solution chosen to fix this bug relies on the default charset
 being UTF-8,
 which is a problem, especially on Windows (where it never is).


 {{{
 ERROR: test_content_saving (file_storage.tests.ContentFileStorageTestCase)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "c:\data\dev\django\django\tests\file_storage\tests.py", line 755,
 in test_content_saving
     self.storage.save('unicode.txt', ContentFile("espa?ol"))
   File "c:\data\dev\django\django\django\core\files\storage.py", line 64,
 in save
     name = self._save(name, content)
   File "c:\data\dev\django\django\django\core\files\storage.py", line 257,
 in _save
     _file.write(chunk)
   File "c:\Python34\lib\encodings\cp1255.py", line 19, in encode
     return codecs.charmap_encode(input,self.errors,encoding_table)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\xf1' in
 position 4:
  character maps to <undefined>
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/19367#comment:9>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.0a8998b2f8ffb1919cdfc9cc5047e618%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to