Commit 08bf1b19 by Adam Charnock Committed by Timothée Peignier

Fixing an issue when for files which contain unicode data

The django.core.files.base module uses the cStringIO package where available. However, unlike StringIO, cStringIO does not support unicode data, and the result is additional null bytes being entered into the output file.

The trick seems to be to convert the data into a byte string before passing it into ContentFile, which I do here using Django's smart_str() utility.

Signed-off-by: Timothée Peignier <timothee.peignier@tryphon.org>
parent 59dbe419
......@@ -2,6 +2,7 @@ import os
import urlparse
from django.core.files.base import ContentFile
from django.utils.encoding import smart_str
from pipeline.conf import settings
from pipeline.compilers import Compiler
......@@ -85,7 +86,7 @@ class Packager(object):
return self.compressor.compile_templates(package['templates'])
def save_file(self, path, content):
return storage.save(path, ContentFile(content))
return storage.save(path, ContentFile(smart_str(content)))
def create_packages(self, config):
packages = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment