Fix Python 3 issues.

This commit is contained in:
Dave Shawley 2015-08-26 15:29:48 -04:00
parent 7e12355311
commit e99e430806
2 changed files with 14 additions and 2 deletions

View file

@ -6,7 +6,7 @@ sprockets.mixins.media_type
import logging
from ietfparse import algorithms, errors, headers
from tornado import web
from tornado import escape, web
version_info = (0, 0, 0)
@ -256,7 +256,8 @@ class _TextContentHandler(object):
def to_bytes(self, data_dict, encoding=None):
selected = encoding or self.default_encoding
content_type = '{0}; charset="{1}"'.format(self.content_type, selected)
return content_type, self._dumps(data_dict).encode(selected)
dumped = self._dumps(escape.recursive_unicode(data_dict))
return content_type, dumped.encode(selected)
def from_bytes(self, data, encoding=None):
return self._loads(data.decode(encoding or self.default_encoding))

11
tox.ini Normal file
View file

@ -0,0 +1,11 @@
[tox]
envlist = py27,py34
indexserver =
default = https://pypi.python.org/simple
toxworkdir = build/tox
[testenv]
deps =
-rrequires/installation.txt
-rrequires/testing.txt
commands = nosetests []