We need text mode for JSON and YAML

This commit is contained in:
Matthias Urlichs committed 2019-01-28 14:14:23 +01:00
1 parent f3fdac7e5a
commit 7fcc3551ca
17 files changed
+26 -26

No files matched your search

+2 -2
View File
@@ -150,11 +150,11 @@ def post_from_file(ctx, path, file_path, json_flag, yaml_flag, timeout):
"""POSTs JSON data to the specified server path, taking the data from the specified file."""
if json_flag or yaml_flag:
if json_flag:
with io.open(file_path, 'rb') as fp:
with io.open(file_path, 'rt') as fp:
data = json.load(fp)
else:
import yaml
with io.open(file_path, 'rb') as fp:
with io.open(file_path, 'rt') as fp:
data = yaml.safe_load(fp)
r = ctx.obj.client.post_json(path, data, timeout=timeout)