simplejson.JSONDecodeError is a child of ValueError, we can just change the error to ValueError and it will work fine for both.
On Wednesday, January 21, 2015 04:00:33 PM Thomas Wood wrote: > The json module raises a ValueError if load() encounters a problem with > the data, but the simplejson module raises a JSONDecodeError exception, > which is not present in the json module. Therefore, check for ValueError > first to avoid an attribute error. > > Signed-off-by: Thomas Wood <[email protected]> > --- > framework/results.py | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/framework/results.py b/framework/results.py > index 5819af5..f1b1b50 100644 > --- a/framework/results.py > +++ b/framework/results.py > @@ -167,6 +167,13 @@ class TestrunResult(object): > with open(os.path.join(results_dir, 'tests', file_), 'r') as f: > try: > test = json.load(f) > + # The json module raises a ValueError if load() encounters a > + # problem with the data, but the simplejson module raises a > + # JSONDecodeError exception, which is not present in the json > + # module. Therefore, check for ValueError first to avoid an > + # attribute error. > + except ValueError: > + continue > except json.JSONDecodeError: > continue > # XXX: There has to be a better way to get a single key: value > out > -- > 2.1.0 > > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit >
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
