mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
prepare formatted content outside of write block
This is specifically to avoid having an exception raised while the file is open for writing. Otherwise, we end up with an empty file if something goes wrong.
This commit is contained in:
+3
-1
@@ -123,8 +123,10 @@ class Project(object):
|
||||
def write_toml(self, data, path=None):
|
||||
if path is None:
|
||||
path = self.pipfile_location
|
||||
|
||||
formatted_data = format_toml(toml.dumps(data))
|
||||
with open(path, 'w') as f:
|
||||
f.write(format_toml(toml.dumps(data)))
|
||||
f.write(formatted_data)
|
||||
|
||||
@property
|
||||
def sources(self):
|
||||
|
||||
Reference in New Issue
Block a user