liblouis
liblouis copied to clipboard
'utf-32-le' codec can't decode bytes in position 0-3 running on s390x arch
Running this script on SUSE on s390x arch raises an exception:
The script:
import louis
with open("braille_result1.txt", 'w') as braille_result1:
print(louis.translate(["unicode.dis","en-chardefs.cti"], "abcdefghijklmnopqrstuvwxyz")[0], file=braille_result1)
with open("braille_result2.txt", 'w') as braille_result2:
print(louis.translate(["unicode.dis","en-chardefs.cti"], "ABCDEFGHIJKLMNOPQRSTUVWXYZ")[0], file=braille_result2)
symbols = ' !"#$%()*+-./:;<=>?@[\]_{}~123456790'+"'"
with open("braille_result3.txt", 'w') as braille_result3:
print(louis.translate(["unicode.dis","en-chardefs.cti"], symbols)[0], file=braille_result3)
The exception:
Traceback (most recent call last):
File "/home/abuild/rpmbuild/SOURCES/script.py", line 4, in <module>
print(louis.translate(["unicode.dis","en-chardefs.cti"], "abcdefghijklmnopqrstuvwxyz")[0], file=braille_result1)
File "/home/abuild/rpmbuild/BUILDROOT/liblouis-3.20.0-150400.3.16.1.s390x/usr/lib/python3.6/site-packages/louis/__init__.py", line 273, in translate
conversionEncoding, errors=ENCODING_ERROR_HANDLER
File "/usr/lib64/python3.6/encodings/utf_32_le.py", line 11, in decode
return codecs.utf_32_le_decode(input, errors, True)
UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 0-3: code point not in range(0x110000)
error: Bad exit status from /var/tmp/rpm-tmp.WTeQT8 (%check)
I've noticed that changing the conversionEncoding line in the init.py file to utf_%d_be fixes the problem for this architecture, but I'm not sure if this is a correct fix or if it can have some side effect.