Moved from #134
One of my documents contains a field, which is checked against a pattern.
When I put a UTF-8 character into the field, I should have gotten a ValidationError?, but I got, when calling pyxb.ValidationError?.details():
Traceback (most recent call last):
...
File "/usr/local/lib/python2.7/dist-packages/pyxb/exceptions_.py", line 183, in details
return str(self)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 116: ordinal not in range(128)
My calling code:
try:
xml = file(args.exp_file).read()
exp = expxml.CreateFromDocument(xml)except pyxb.ValidationError as e:
log.error("Error validating %s: %s"
% (args.exp_file, e.details()))
sys.exit(-1)
I'm using Python 2.7. I don't think this is a Python issue.
You did get a validation error. The convenience method that provides the exception description as a string is not prepared to incorporate unicode components. I'll have to review how that's handled in other library routines these days, and review each exception for cases where this might occur. For now you'll need to check the type of the exception and extract the error information from exception's attributes. It's probably a SimpleFacetValueError, and the value attribute is probably not interpretable without an explicit encoding.
resolution set to fixed
commit 72e08980300500aa1173786c95669fb533a107b8
Author: Peter A. Bigot pab@pabigot.com
Date: Mon Apr 15 11:24:46 2013 -0500