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

Test fail on big-endian (s390x) #12

Open
ptrcnull opened this issue Jul 27, 2022 · 3 comments
Open

Test fail on big-endian (s390x) #12

ptrcnull opened this issue Jul 27, 2022 · 3 comments

Comments

@ptrcnull
Copy link

Example from Alpine Linux edge: https://gitlab.alpinelinux.org/ptrcnull/aports/-/jobs/783199#L149

======================================================================
FAIL: test_empty (pythongettext.tests.test_compile.TestWriter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/ptrcnull/aports/community/py3-gettext/src/python-gettext-4.0/pythongettext/tests/test_compile.py", line 30, in test_empty
    self.compare_po_mo('test_empty.po', 'test_empty.mo')
  File "/builds/ptrcnull/aports/community/py3-gettext/src/python-gettext-4.0/pythongettext/tests/test_compile.py", line 27, in compare_po_mo
    self.assertEqual(mo, po)
AssertionError: b'\xde\x12\x04\x95\x00\x00\x00\x00\x00\x00\x0[65 chars]\x00' != b'\x95\x04\x12\xde\x00\x00\x00\x00\x00\x00\x0[65 chars]\x1c'
@icemac
Copy link
Collaborator

icemac commented Aug 2, 2022

@ptrcnull Thank you for writing this issue. Do you have a suggestion how to solve it?

@ptrcnull
Copy link
Author

ptrcnull commented Aug 2, 2022

only partially; forcing endianness in struct.pack helps a little:

diff --git a/pythongettext/msgfmt.py b/pythongettext/msgfmt.py
index 6641b52..61c4615 100755
--- a/pythongettext/msgfmt.py
+++ b/pythongettext/msgfmt.py
@@ -150,7 +150,7 @@ class Msgfmt:
         # Even though we don't use a hashtable, we still set its offset to be
         # binary compatible with the gnu gettext format produced by:
         # msgfmt file.po --no-hash
-        output = struct.pack("Iiiiiii",
+        output = struct.pack("<Iiiiiii",
                              0x950412de,        # Magic
                              0,                 # Version
                              len(keys),         # # of entries

but that doesn't solve the issue entirely

@icemac
Copy link
Collaborator

icemac commented Aug 26, 2022

Since the merge of #13 we have automatic tests for this repository, so the behavior could be explored using GitHub Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants