diff --git a/pipenv/project.py b/pipenv/project.py index 7f40576d99..d0d21c3eca 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -14,6 +14,7 @@ import six import toml import json as simplejson +from prettytoml.elements.array import ArrayElement from ._compat import Path @@ -64,6 +65,12 @@ def _normalized(p): DEFAULT_NEWLINES = u"\n" +def encode_toml_elements(obj): + if isinstance(obj, ArrayElement): + return obj.primitive_value + raise TypeError(repr(obj) + " is not JSON serializable") + + def preferred_newlines(f): if isinstance(f.newlines, six.text_type): return f.newlines @@ -631,7 +638,8 @@ def write_lockfile(self, content): """ newlines = self._lockfile_newlines s = simplejson.dumps( # Send Unicode in to guarentee Unicode out. - content, indent=4, separators=(u",", u": "), sort_keys=True + content, indent=4, separators=(u",", u": "), sort_keys=True, + default=encode_toml_elements, ) with atomic_open_for_write(self.lockfile_location, newline=newlines) as f: f.write(s)