From fb9fb2e57542580f7feb2ec2ddca58d3129fb8ef Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Fri, 4 May 2018 00:58:32 +0800 Subject: [PATCH] Simplify JSON dump compatibility code --- pipenv/project.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index 58cbb1ba..d9bbc385 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -634,20 +634,17 @@ class Project(object): self.clear_pipfile_cache() def write_lockfile(self, content): - # Write out the lockfile. + """Write out the lockfile. + """ newlines = self._lockfile_newlines - s = simplejson.dumps( - content, indent=4, separators=(',', ': '), sort_keys=True + s = simplejson.dumps( # Send Unicode in to guarentee Unicode out. + content, indent=4, separators=(u',', u': '), sort_keys=True, ) - - if sys.version_info[0] < 3: - s = s.decode('ascii') - with atomic_open_for_write(self.lockfile_location, newline=newlines) as f: - # Write newline at end of document. GH Issue #319. + f.write(s) + # Write newline at end of document. GH#319. if not s.endswith(newlines): - s = '{0}{1}'.format(s, newlines) - f.write(u'{0}'.format(s)) + f.write(newlines) @property def pipfile_sources(self):