From c7147db666daa293c1ecab876d813d7a8aa4e314 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 19 Jun 2020 11:26:08 -0700 Subject: [PATCH] Allow ValueError to pass-through without exception conversion. This maintains compatibility with the Python json library which raises ValueError when it cannot parse a file. --- commentjson/commentjson.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commentjson/commentjson.py b/commentjson/commentjson.py index 4702057..e927940 100755 --- a/commentjson/commentjson.py +++ b/commentjson/commentjson.py @@ -201,6 +201,10 @@ def load(fp, **kwargs): try: return loads(fp.read(), **kwargs) + except ValueError: + # pass through ValueError since that likely just indicates a bad + # JSON file and ValueError is how the json library signals that. + raise except Exception as e: raise JSONLibraryException(e)