Skip to content

Commit 3b2f538

Browse files
committed
Make json.dump compatible with py2 and py3
1 parent da1fde3 commit 3b2f538

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

readthedocs/doc_builder/python_environments.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ def save_environment_json(self):
159159
'image': build_image,
160160
},
161161
}
162+
162163
with open(self.environment_json_path(), 'w') as fpath:
163-
json.dump(data, fpath)
164+
# Compatibility for Py2 and Py3. ``io.TextIOWrapper`` expects
165+
# unicode but ``json.dumps`` returns str in Py2.
166+
fpath.write(unicode(json.dumps(data)))
164167

165168

166169
class Virtualenv(PythonEnvironment):

0 commit comments

Comments
 (0)