tomerfiliba-org/reedsolomon

Encoder returns empty array

za3k opened this issue · 3 comments

za3k commented

This code:

import reedsolo
reedsolo.RSCodec(300).encode(b'a')

Returns bytearray(b'') on my computer. Adjusting the number down causes it to return something.

za3k commented

Oh also, in case it's an issue with potential string lengths, reedsolo.RSCodec(300, c_exp=12).encode(b'a') instead outputs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 893, in encode
    enc.extend(rs_encode_msg(chunk, self.nsym, fcr=self.fcr, generator=self.generator, gen=self.gen[nsym]))
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 514, in rs_encode_msg
    msg_in = _bytearray(msg_in)
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 279, in _bytearray
    return array("i", obj)
ValueError: bytes length not a multiple of item size

About your first question, it's an uncaught error but it's normal, this happens because you initialized RSCodec with too many ECC symbols (300) when by default the max total message length nsize=255. Now there will be an error message.

About your second question, this was indeed a bug, which was kindly fixed by someone else in #46 and is now merged, so this bug does not happen anymore.

za3k commented

Thanks for adding an error