Skip to content

Commit

Permalink
Fix unmarshaling tests on big endian systems.
Browse files Browse the repository at this point in the history
Fix about eight unmarshaling error similar to:

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/usr/lib/python3.11/unittest/case.py", line 623, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
    if method() is not None:
  File "/home/hugh/txdbus/tests/test_marshal.py", line 487, in test_bad_length
    self.assertRaises(
  File "/usr/lib/python3.11/unittest/case.py", line 766, in assertRaises
    return context.handle('assertRaises', args, kwargs)
  File "/usr/lib/python3.11/unittest/case.py", line 237, in handle
    callable_obj(*args, **kwargs)
  File "/home/hugh/txdbus/tests/test_marshal.py", line 352, in check
    nbytes, value = m.unmarshal(sig, encoding, 0)
  File "/home/hugh/txdbus/txdbus/marshal.py", line 887, in unmarshal
    nbytes, value = unmarshallers[tcode](ct, data, offset, lendian, oobFDs)
  File "/home/hugh/txdbus/txdbus/marshal.py", line 789, in unmarshal_array
    nbytes, value = unmarshallers[tcode](
  File "/home/hugh/txdbus/txdbus/marshal.py", line 812, in unmarshal_struct
    return unmarshal(ct[1:-1], data, offset, lendian, oobFDs)
  File "/home/hugh/txdbus/txdbus/marshal.py", line 887, in unmarshal
    nbytes, value = unmarshallers[tcode](ct, data, offset, lendian, oobFDs)
  File "/home/hugh/txdbus/txdbus/marshal.py", line 706, in unmarshal_int32
    return 4, struct.unpack_from(lendian and '<i' or '>i', data, offset)[0]
struct.error: unpack_from requires a buffer of at least 28 bytes for unpacking 4 bytes at offset 24 (actual buffer size is 24)

tests.test_marshal.TestArrayUnmarshal.test_bad_length
===============================================================================
  • Loading branch information
Hugh Daschbach authored and hdasch committed Sep 13, 2024
1 parent 62d86b9 commit 22f6934
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def check_dict(a, b):
class TestUnmarshal(unittest.TestCase):

def check(self, sig, expected_value, encoding):
nbytes, value = m.unmarshal(sig, encoding, 0)
nbytes, value = m.unmarshal(sig, encoding, 0, sys.byteorder == 'little')
self.assertEqual(
nbytes,
len(encoding),
Expand Down

0 comments on commit 22f6934

Please sign in to comment.