Fix xs:error type decoding/encoding

This commit is contained in:
Davide Brunato 2019-10-10 20:34:40 +02:00
parent 1a06be7477
commit 588f17a1f9
1 changed files with 9 additions and 0 deletions

View File

@ -549,6 +549,11 @@ class XsdAtomicBuiltin(XsdAtomic):
yield self.decode_error(validation, obj, self.to_python, reason=str(err))
yield None
return
except TypeError:
# xs:error type (eg. an XSD 1.1 type alternative used to catch invalid values)
yield self.validation_error(validation, "Invalid value {!r}".format(obj))
yield None
return
for validator in self.validators:
for error in validator(result):
@ -587,6 +592,10 @@ class XsdAtomicBuiltin(XsdAtomic):
yield self.encode_error(validation, obj, self.from_python)
yield None
return
except TypeError:
yield self.validation_error(validation, "Invalid value {!r}".format(obj))
yield None
return
for validator in self.validators:
for error in validator(obj):