pyfec: fix bug in easyfec
authorzooko <zooko@zooko.com>
Wed, 28 Mar 2007 05:56:45 +0000 (11:26 +0530)
committerzooko <zooko@zooko.com>
Wed, 28 Mar 2007 05:56:45 +0000 (11:26 +0530)
darcs-hash:879246ab55ce272c6df2c433d970a888f4b2fc53

pyfec/fec/easyfec.py

index 3c0581306ed45e4e49b233656e5b07317ba56534..a2b5ec4d53da5ee7a26dce65aa81ef2220f92a55 100644 (file)
@@ -18,7 +18,8 @@ class Encoder(object):
         """
         chunksize = div_ceil(len(data), self.fec.k)
         numchunks = div_ceil(len(data), chunksize)
-        l = [ data[i:i+chunksize] for i in range(numchunks) ]
+        l = [ data[i:i+chunksize] for i in range(0, len(data), chunksize) ]
+        # padding
         if len(l[-1]) != len(l[0]):
             l[-1] = l[-1] + ('\x00'*(len(l[0])-len(l[-1])))
         return self.fec.encode(l)