mirror of
https://github.com/httpie/cli.git
synced 2025-02-02 02:39:19 +01:00
Split session JSON serialization and writing to file
To avoid writing invalid JSON in case of presence of unserializable data due to an internal bug.
This commit is contained in:
parent
9931747901
commit
0d480139e4
@ -108,16 +108,14 @@ class BaseConfigDict(dict):
|
|||||||
|
|
||||||
self.ensure_directory()
|
self.ensure_directory()
|
||||||
|
|
||||||
try:
|
json_string = json.dumps(
|
||||||
with self.path.open('w') as f:
|
|
||||||
json.dump(
|
|
||||||
obj=self,
|
obj=self,
|
||||||
fp=f,
|
|
||||||
indent=4,
|
indent=4,
|
||||||
sort_keys=True,
|
sort_keys=True,
|
||||||
ensure_ascii=True,
|
ensure_ascii=True,
|
||||||
)
|
)
|
||||||
f.write('\n')
|
try:
|
||||||
|
self.path.write_text(json_string + '\n')
|
||||||
except IOError:
|
except IOError:
|
||||||
if not fail_silently:
|
if not fail_silently:
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user