check-json: resolve TODO
diff --git a/pre_commit_hooks/check_json.py b/pre_commit_hooks/check_json.py
index 25dbfd9..6026270 100644
--- a/pre_commit_hooks/check_json.py
+++ b/pre_commit_hooks/check_json.py
@@ -14,8 +14,7 @@
with open(filename, 'rb') as f:
try:
json.load(f)
- # TODO: need UnicodeDecodeError?
- except (ValueError, UnicodeDecodeError) as exc:
+ except ValueError as exc:
print(f'{filename}: Failed to json decode ({exc})')
retval = 1
return retval
diff --git a/tests/check_json_test.py b/tests/check_json_test.py
index 6654ed1..c63dc4c 100644
--- a/tests/check_json_test.py
+++ b/tests/check_json_test.py
@@ -17,3 +17,9 @@
if expected_retval == 1:
stdout, _ = capsys.readouterr()
assert filename in stdout
+
+
+def test_non_utf8_file(tmpdir):
+ f = tmpdir.join('t.json')
+ f.write_binary(b'\xa9\xfe\x12')
+ assert main((str(f),))