Skip to content

Commit ce0d611

Browse files
committed
Fix call to sorted by providing key to sort on.
This call to sorted does nothing in Python 2, as there is no way to sort a list of Exceptions without providing a key. In Python 3 this call fails with an error as there is no comparison implemented for the jsonschema.exceptions.ValidationError Exception. This is fixed by providing the key str, which sorts by the str representation of the Exception.
1 parent 49b158b commit ce0d611

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/config/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,9 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
511511
resolver = RefResolver(uri, schema)
512512
validator = Draft4Validator(schema, resolver=resolver)
513513

514-
errors = sorted(validator.iter_errors(self.app_config_data))
514+
errors = sorted(
515+
validator.iter_errors(self.app_config_data), key=str
516+
)
515517

516518
if errors:
517519
raise ConfigException("; ".join(
@@ -583,7 +585,7 @@ def add_config_files(self, flist):
583585
resolver = RefResolver(uri, schema_file)
584586
validator = Draft4Validator(schema_file, resolver=resolver)
585587

586-
errors = sorted(validator.iter_errors(cfg))
588+
errors = sorted(validator.iter_errors(cfg), key=str)
587589

588590
if errors:
589591
raise ConfigException("; ".join(

0 commit comments

Comments
 (0)