Forums » Saxon/C Help and Discussions »
Should print(result) in Python work where result = xpath_processor.evaluate()?
Added by Martin Honnen almost 5 years ago
I have managed to build the Python HE 1.2.0 module on Windows 10 64bit but I am struggling with some simple things like trying to output results.
For the sample Python program
import saxonc
with saxonc.PySaxonProcessor(license=False) as proc:
print(proc.version)
xpathProcessor = proc.new_xpath_processor()
result = xpathProcessor.evaluate('(1, 2, 3, 4, 5)')
print(result.item_at(0))
print(result)
I get an output for the first print()
call but then an error on the second
Traceback (most recent call last):
File "C:\SomeFolder\saxonc-1.2-python\xpath-test4.py", line 12, in <module>
print(result)
File "saxonc.pyx", line 3257, in saxonc.PyXdmValue.__str__
ustring = c_string.decode('UTF-8') if c_string is not NULL else None
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 0: unexpected end of data
Is that expected?
Replies (8)
Please register to reply
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
Hi Martin,
Thanks for reporting this issue.
This looks like a bug to me. The PyXdmValue class should be converting itself to a serialised string but the str function is failing.
I will investigate this further.
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
This bug has now been resolved in the files mentioned in the bug issue #4352
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by Martin Honnen almost 5 years ago
I am still getting the error, only with a slightly different line number:
Traceback (most recent call last):
File ".\xpath-test4.py", line 12, in <module>
print(result)
File "saxonc.pyx", line 3260, in saxonc.PyXdmValue.__str__
ustring = c_string.decode('UTF-8') if c_string is not NULL else None
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 0: unexpected end of data
on the print(result)
call.
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
Yes you are right. Investigating this issue.
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
Bug fixed. Changes made to the saxonc.pyx, XdmValue.h and XdmValue.cpp files.
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by Martin Honnen almost 5 years ago
I have the Python code running on one machine but I had to update a lot of more files like https://dev.saxonica.com/repos/archive/opensource/latest9.9/hec/Saxon.C.API/SaxonProcessor.h or saxoncClasses.pxd before the saxon-setup.py build_ext -if
worked , so thanks for all the fixes.
As it is a bit difficult keeping track of all the changes, are you planning a 1.2.1 release as soon as you have fixed the currently known issues?
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
I had hoped to get a release out this week but now hitting some memory issues with XdmValues, which is holding the release up. I am still investigating it.
RE: Should print(result) in Python work where result = xpath_processor.evaluate()? - Added by O'Neil Delpratt almost 5 years ago
Memory issue fixed. Now doing a full test. Therefore hopefully a release tomorrow.
Please register to reply