diff roundup/rest.py @ 8220:818751637b77

fix: make rest.py still load on python2, do not test bad json It's not worth fixing the test to make it work on python2. But do define the missing JSONDecodeError as it's base class ValueError on python2.
author John Rouillard <rouilj@ieee.org>
date Tue, 17 Dec 2024 21:42:45 -0500
parents 32aaf5dc562b
children 54afcb9149eb
line wrap: on
line diff
--- a/roundup/rest.py	Tue Dec 17 20:45:28 2024 -0500
+++ b/roundup/rest.py	Tue Dec 17 21:42:45 2024 -0500
@@ -19,6 +19,11 @@
 from hashlib import md5
 
 try:
+    from json import JSONDecodeError
+except ImportError:
+    JSONDecodeError = ValueError
+
+try:
     from urllib.parse import urlparse
 except ImportError:
     from urlparse import urlparse
@@ -2747,7 +2752,7 @@
                                     parse_constant=raise_error_on_constant)
             self.value = [self.FsValue(index, self.json_dict[index])
                           for index in self.json_dict]
-        except (json.decoder.JSONDecodeError, ValueError) as e:
+        except (JSONDecodeError, ValueError) as e:
             raise ValueError(e.args[0] + ". JSON is: " + json_string)
 
 

Roundup Issue Tracker: http://roundup-tracker.org/