Attempt to fix the json hook under test

This commit is contained in:
Anthony Sottile
2017-03-20 10:42:48 -07:00
parent a8592669d9
commit dc50b7f09c
2 changed files with 8 additions and 11 deletions

View File

@ -1,10 +1,10 @@
from __future__ import print_function
import argparse
import io
import json
import sys
import simplejson
def check_json(argv=None):
parser = argparse.ArgumentParser()
@ -14,8 +14,8 @@ def check_json(argv=None):
retval = 0
for filename in args.filenames:
try:
simplejson.load(open(filename))
except (simplejson.JSONDecodeError, UnicodeDecodeError) as exc:
json.load(io.open(filename, encoding='UTF-8'))
except (ValueError, UnicodeDecodeError) as exc:
print('{}: Failed to json decode ({})'.format(filename, exc))
retval = 1
return retval