Commits

Anonymous committed d818f93

text_handler: hexadecimal() allows field of any size (align size to 4-bit)

Comments (0)

Files changed (1)

hachoir-core/hachoir_core/text_handler.py

     humanFrequency as doHumanFrequency,
     timestampUNIX as doTimestampUNIX,
     humanDatetime,
+    alignValue,
 )
 from hachoir_core.i18n import _
 
     """
     assert hasattr(field, "value") and hasattr(field, "size")
     size = field.size
-    assert 0 < size <= 64 and not size % 8
-    pattern = u"0x%%0%ux" % (size/4)
+#    assert 0 < size <= 64 and not size % 8
+    padding = alignValue(size, 4) // 4
+    pattern = u"0x%%0%ux" % padding
     return pattern % field.value