Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'utf-32-le' codec can't decode bytes in position 0-3 running on s390x arch #1551

Closed
danigm opened this issue Apr 9, 2024 · 0 comments · Fixed by #1552
Closed

'utf-32-le' codec can't decode bytes in position 0-3 running on s390x arch #1551

danigm opened this issue Apr 9, 2024 · 0 comments · Fixed by #1552
Assignees
Labels
python An issue concerning the Python bindings
Milestone

Comments

@danigm
Copy link
Contributor

danigm commented Apr 9, 2024

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.

danigm added a commit to danigm/liblouis that referenced this issue Apr 11, 2024
egli pushed a commit to danigm/liblouis that referenced this issue May 13, 2024
@egli egli added this to the 3.30 milestone May 13, 2024
@bertfrees bertfrees added the python An issue concerning the Python bindings label May 15, 2024
@egli egli self-assigned this May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python An issue concerning the Python bindings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants