Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
liblouis.33555
s390x-support.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File s390x-support.patch of Package liblouis.33555
From e11dfbc7539e31be5e4381e416874ad22e408502 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno <daniel.garcia@suse.com> Date: Thu, 11 Apr 2024 13:35:03 +0200 Subject: [PATCH] python: use utf_%d_be encoding on bigendian archs Fix https://github.com/liblouis/liblouis/issues/1551 --- python/louis/__init__.py.in | 5 +++-- python/tests/test_louis.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) Index: liblouis-3.20.0/python/louis/__init__.py.in =================================================================== --- liblouis-3.20.0.orig/python/louis/__init__.py.in +++ liblouis-3.20.0/python/louis/__init__.py.in @@ -39,7 +39,7 @@ function for information about how liblo @author: Andre-Abush Clause <dev@andreabc.net> """ -from sys import getfilesystemencoding, platform, version_info +from sys import byteorder, getfilesystemencoding, platform, version_info from atexit import register from ctypes import ( c_ushort, @@ -60,6 +60,7 @@ except ImportError: # Unix/Cygwin _loader, _functype = cdll, CFUNCTYPE liblouis = _loader["###LIBLOUIS_SONAME###"] _is_windows = platform == "win32" +_endianness = "be" if byteorder == "big" else "le" # { Module Configuration #: Specifies the charSize (in bytes) used by liblouis. @@ -78,7 +79,7 @@ outlenMultiplier = 4 + wideCharBytes * 2 fileSystemEncoding = "mbcs" if _is_windows else getfilesystemencoding() #: Specifies the encoding to use when converting from byte strings to unicode strings. #: @type: str -conversionEncoding = "utf_%d_le" % (wideCharBytes * 8) +conversionEncoding = "utf_%d_%s" % (wideCharBytes * 8, _endianness) # } # Some general utility functions Index: liblouis-3.20.0/python/test_louis.py =================================================================== --- /dev/null +++ liblouis-3.20.0/python/test_louis.py @@ -0,0 +1,16 @@ +import pytest +import louis + + +def test_translate(): + assert louis.translate(["unicode.dis","en-chardefs.cti"], "abcdefghijklmnopqrstuvwxyz")[0] == "⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵" + + +def test_translate_fail(): + # invert encoding + _encoding = louis.conversionEncoding + _endianness = "le" if louis._endianness == "be" else "be" + louis.conversionEncoding = "utf_%d_%s" % (louis.wideCharBytes * 8, _endianness) + with pytest.raises(UnicodeDecodeError) as context: + louis.translate(["unicode.dis","en-chardefs.cti"], "abcdefghijklmnopqrstuvwxyz") + louis.conversionEncoding = _encoding
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor