use ValueError instead of JSONDecodeError

JSONDecodeError is only available in never python 3 versions and still
inherits from ValueError, so we could just use it.

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-04-24 05:09:48 +03:00
parent b97b99cf15
commit 49f87a5bff
3 changed files with 4 additions and 4 deletions
+3 -2
View File
@@ -96,11 +96,12 @@ class Analytics(object):
with open(self.user_id_file, "r") as fobj:
try:
info = json.load(fobj)
return info[self.PARAM_USER_ID]
except json.JSONDecodeError as exc:
except ValueError as exc:
logger.debug("Failed to load user_id: {}".format(exc))
return None
return info[self.PARAM_USER_ID]
def _get_user_id(self):
from dvc.lock import LockError
+1 -1
View File
@@ -225,7 +225,7 @@ class RemoteBase(object):
try:
with open(path, "r") as fobj:
d = json.load(fobj)
except json.JSONDecodeError:
except ValueError:
logger.exception("Failed to load dir cache '{}'".format(path_info))
return []
finally:
-1
View File
@@ -5,7 +5,6 @@ import sys
import os
import errno
# Syntax sugar.
_ver = sys.version_info