Skip to content

Commit 3e8884f

Browse files
RomainTTRomain Taprest
authored and
Romain Taprest
committed
[CLI] Replace JSONDecodeError by ValueError for 2.7 compat
1 parent bcd39ab commit 3e8884f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jsonschema/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def parse_args(args):
184184
def make_validator(schema_path, validator_class, output_writer):
185185
try:
186186
schema_obj = _load_json_file(schema_path)
187-
except (json.JSONDecodeError, FileNotFoundError) as exc:
187+
except (ValueError, FileNotFoundError) as exc:
188188
output_writer.write_parsing_error(schema_path, exc)
189189
raise exc
190190

@@ -201,7 +201,7 @@ def make_validator(schema_path, validator_class, output_writer):
201201
def load_stdin(stdin, output_writer):
202202
try:
203203
instance_obj = json.load(stdin)
204-
except json.JSONDecodeError as exc:
204+
except ValueError as exc:
205205
output_writer.write_parsing_error("stdin", exc)
206206
raise exc
207207
return instance_obj
@@ -210,7 +210,7 @@ def load_stdin(stdin, output_writer):
210210
def load_instance_file(instance_path, output_writer):
211211
try:
212212
instance_obj = _load_json_file(instance_path)
213-
except (json.JSONDecodeError, FileNotFoundError) as exc:
213+
except (ValueError, FileNotFoundError) as exc:
214214
output_writer.write_parsing_error(instance_path, exc)
215215
raise exc
216216
return instance_obj
@@ -246,7 +246,7 @@ def run(arguments, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin):
246246
arguments["validator"],
247247
output_writer,
248248
)
249-
except (FileNotFoundError, json.JSONDecodeError, SchemaError):
249+
except (FileNotFoundError, ValueError, SchemaError):
250250
return False
251251

252252
errored = False
@@ -259,7 +259,7 @@ def run(arguments, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin):
259259
validator,
260260
output_writer,
261261
)
262-
except (json.JSONDecodeError, FileNotFoundError, ValidationError):
262+
except (ValueError, FileNotFoundError, ValidationError):
263263
errored = True
264264
elif (
265265
stdin is sys.stdin and not sys.stdin.isatty()
@@ -272,7 +272,7 @@ def run(arguments, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin):
272272
validator,
273273
output_writer,
274274
)
275-
except (json.JSONDecodeError, ValidationError):
275+
except (ValueError, ValidationError):
276276
errored = True
277277

278278
return errored

0 commit comments

Comments
 (0)