Fix utf8 errors

Fix #681
pull/712/head
Julien Duponchelle 8 years ago
parent ac8bd3fec4
commit cf10f02a8d
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

@ -648,7 +648,7 @@ class Project:
topo = project_to_topology(self)
path = self._topology_file()
log.debug("Write %s", path)
with open(path + ".tmp", "w+") as f:
with open(path + ".tmp", "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
shutil.move(path + ".tmp", path)
except OSError as e:

@ -89,7 +89,7 @@ def load_topology(path):
"""
log.debug("Read topology %s", path)
try:
with open(path) as f:
with open(path, encoding="utf-8") as f:
topo = json.load(f)
except (OSError, UnicodeEncodeError, json.JSONDecodeError) as e:
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
@ -98,7 +98,7 @@ def load_topology(path):
# first we backup the file
shutil.copy(path, path + ".backup")
topo = _convert_1_3_later(topo, path)
with open(path, "w+") as f:
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f)
elif topo["revision"] > GNS3_FILE_FORMAT_REVISION:
raise aiohttp.web.HTTPConflict(text="This project is designed for a more recent version of GNS3 please update GNS3 to version {} or later".format(topo["version"]))

Loading…
Cancel
Save