Commits

Christian Tismer  committed fe2522c

this code should get a generator/iterator protocol to keep the chunk size limited

  • Participants
  • Parent commits 9736584

Comments (0)

Files changed (1)

File tiffany/monkeypil.py

 
         def encode_to_file(self, fh, bufsize):
             # we ignore the bufsize and just copy over
+            # XXX modify that and implement a generator protocol!
             src = self.src_fp
             for ofs, lng in self.strips:
                 src.seek(ofs)
 
         def encode(self, bufsize):
             # we ignore the bufsize and just copy over
+            # XXX modify that and implement a generator protocol!
             src = self.src_fp
             ret = src.read(0)  # compatible empty string/bytes
             for ofs, lng in self.strips:
                 src.seek(ofs)
-                ret += src.read(lng)
+                buf = src.read(lng)
+                ret += buf
             return None, 1, ret
 
     def tiffany_encoder(self, mode, source, *strips):
 
 
 """
-Towards python3 compatibility
------------------------------
+Building python3 compatibility
+------------------------------
 
 In the case of the new io.BytesIO objects (supported in python 2.7,
 required in python 3) we need a little wrapper that emulates the