diff --git a/osa_toolkit/filesystem.py b/osa_toolkit/filesystem.py index 4e30046bb8..b7742db70b 100644 --- a/osa_toolkit/filesystem.py +++ b/osa_toolkit/filesystem.py @@ -193,7 +193,7 @@ def write_hostnames(save_path, hostnames_ips): indent=4, separators=(',', ': '), sort_keys=True - ) + ).encode('ascii') ) @@ -212,7 +212,7 @@ def _load_from_json(filename, preferred_path=None, raise_if_missing=True): dictionary = False if target_file is not False: with open(target_file, 'rb') as f_handle: - dictionary = json.loads(f_handle.read()) + dictionary = json.loads(f_handle.read().decode('ascii')) return dictionary, target_file @@ -264,7 +264,7 @@ def save_inventory(inventory_json, save_path): else: inventory_file = os.path.join(save_path, INVENTORY_FILENAME) with open(inventory_file, 'wb') as f: - f.write(inventory_json) + f.write(inventory_json.encode('ascii')) logger.info("Inventory written") diff --git a/tests/test_inventory.py b/tests/test_inventory.py index 5d0a3e1244..4f2b864212 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -570,7 +570,7 @@ class TestConfigCheckBase(unittest.TestCase): self.config_changed = True # Save new user_config_file with open(USER_CONFIG_FILE, 'wb') as f: - f.write(yaml.dump(self.user_defined_config)) + f.write(yaml.dump(self.user_defined_config).encode('ascii')) def restore_config(self): # get back our initial user config file