tomerfiliba-org / reedsolomon

⏳🛡 Pythonic universal errors-and-erasures Reed-Solomon codec to protect your data from errors and bitrot. Includes a future-proof zero-dependencies pure-python implementation 🔮 and an optional speed-optimized Cython/C extension 🚀
http://pypi.python.org/pypi/reedsolo
Other
352 stars 86 forks source link

Bug in bytearray from decoder #23

Closed HaolingZHANG closed 1 year ago

HaolingZHANG commented 4 years ago

Hi,

I found a bug in the decoding part. It is good in Windows. In Linux and Mac OS, we found the decoder return a list [bytearray 1, bytearray 2, bytearray 3] not just a bytearray. The bytearray 1 is what we need in the decoding part. However, I am not sure why it is different in different operating systems.

In my package, we do the follow sentence to fix this problem (TypeError: 'bytearray' object cannot be interpreted as an integer):

self.tool = RSCodec(3)

decode_byte_list = list(self.tool.decode(byte_list))

if type(decode_byte_list[0]) is not int:
    decode_byte_list = list(decode_byte_list[0])

Best and FYI,

Zhang

lrq3000 commented 1 year ago

It's not a bug, it's a feature. Reedsolo was changed around the time you opened your issue to return 3 bytearrays, to allow for a finer grained control:

decoded_msg, decoded_msgecc, errata_pos = rsc.decode(tampered_msg)

First is the decoded/repaired message, second is the decoded message and error correction code (because both get repaired in reality), third is the position of the errors and erasures.