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
351 stars 86 forks source link

Cython check error: "object has no attribute 'chunk'" #44

Closed henla464 closed 1 year ago

henla464 commented 2 years ago

I tried to use cython and installed with
sudo python3 setup.py install --native-compile

Installation seem to have worked but I get this error calling the check method:

File "creedsolo.pyx", line 870, in creedsolo.RSCodec.check AttributeError: 'RSCodec' object has no attribute 'chunk'

Am I doing something wrong?

henla464 commented 2 years ago

Changing the check function in creedsolo.pyx to the below code seem to fix the issue.

def check(self, data, nsym=None):
        '''Check if a message+ecc stream is not corrupted (or fully repaired). Note: may return a wrong result if number of errors > nsym.'''
        if not nsym:
            nsym = self.nsym
        if isinstance(data, str):
            data = bytearray(data)
        check = []
        for i in xrange(0, len(data), self.nsize):
            # Split the long message in a chunk
            chunk = data[i:i+self.nsize]
            check.append(rs_check(chunk, nsym, fcr=self.fcr, generator=self.generator))
        return check
lrq3000 commented 1 year ago

You are totally right, thank you very much, next time open a PR so you can be directly credited, but I mentioned you in the commit, have a great day!