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.
pull/12275/head
Michael Quested 2020-01-17 13:04:57 +00:00
parent 49b158bdc3
commit ce0d611dd0
1 changed files with 4 additions and 2 deletions

View File

@ -511,7 +511,9 @@ class Config(object):
resolver = RefResolver(uri, schema)
validator = Draft4Validator(schema, resolver=resolver)
errors = sorted(validator.iter_errors(self.app_config_data))
errors = sorted(
validator.iter_errors(self.app_config_data), key=str
)
if errors:
raise ConfigException("; ".join(
@ -583,7 +585,7 @@ class Config(object):
resolver = RefResolver(uri, schema_file)
validator = Draft4Validator(schema_file, resolver=resolver)
errors = sorted(validator.iter_errors(cfg))
errors = sorted(validator.iter_errors(cfg), key=str)
if errors:
raise ConfigException("; ".join(