Use compatible Py2/3 text type by using six
@@ -8,6 +8,7 @@ import json
import logging
import os
import shutil
+import six
from builtins import object, open
from django.conf import settings
@@ -163,7 +164,7 @@ class PythonEnvironment(object):
with open(self.environment_json_path(), 'w') as fpath:
# Compatibility for Py2 and Py3. ``io.TextIOWrapper`` expects
# unicode but ``json.dumps`` returns str in Py2.
- fpath.write(unicode(json.dumps(data)))
+ fpath.write(six.text_type(json.dumps(data)))
class Virtualenv(PythonEnvironment):
