Skip to content

Commit

Permalink
Replace JSONDecodeError by ValueError (Python 3.4 compatibility)
Browse files Browse the repository at this point in the history
Fix #847
  • Loading branch information
julien-duponchelle committed Dec 21, 2016
1 parent 8c61ef1 commit e53db1e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gns3server/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def load(self):
self.save()
with open(self._config_file) as f:
data = json.load(f)
except (OSError, json.decoder.JSONDecodeError) as e:
except (OSError, ValueError) as e:
log.critical("Cannot load %s: %s", self._config_file, str(e))
return

Expand Down
2 changes: 1 addition & 1 deletion gns3server/controller/gns3vm/virtualbox_gns3_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _get_ip(self, hostonly_interface_number, api_port):
if resp:
try:
json_data = yield from resp.json()
except json.decoder.JSONDecodeError:
except ValueError:
pass
resp.close()

Expand Down
2 changes: 1 addition & 1 deletion gns3server/controller/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_topology(path):
try:
with open(path, encoding="utf-8") as f:
topo = json.load(f)
except (OSError, UnicodeDecodeError, json.decoder.JSONDecodeError) as e:
except (OSError, UnicodeDecodeError, ValueError) as e:
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
if "revision" not in topo or topo["revision"] < 5:
# If it's an old GNS3 file we need to convert it
Expand Down
2 changes: 1 addition & 1 deletion scripts/random_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def main(loop):
try:
j = await error.response.json()
die("%s %s invalid status %d:\n%s", error.method, error.path, error.response.status, json.dumps(j, indent=4))
except (json.decoder.JSONDecodeError, aiohttp.errors.ServerDisconnectedError):
except (ValueError, aiohttp.errors.ServerDisconnectedError):
die("%s %s invalid status %d", error.method, error.path, error.response.status)


Expand Down

0 comments on commit e53db1e

Please sign in to comment.