File tree Expand file tree Collapse file tree
wolframclient/serializers/wxfencoder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class ExactSizeReader(object):
3232 def __init__ (self , reader ):
3333 self ._reader = reader
3434
35- @ decorate ( concatenate_bytes )
35+
3636 def read (self , size = - 1 ):
3737 """Read from an underlying readable object.
3838
@@ -45,17 +45,20 @@ def read(self, size=-1):
4545 # Negative values read until EOF and 0 returns b''. Both remain unchanged.
4646 # Also a fast path when the requested amount of bytes is returned in one go.
4747 if size <= 0 or len (data ) == size :
48- yield data
49- else :
50- # need an intermediary buffer
51- out_len = len (data )
52- while out_len < size :
53- chunk = self ._reader .read (size - out_len )
54- if chunk == b"" :
55- raise EOFError ("Not enough data to read." )
56- yield chunk
57- out_len = out_len + len (chunk )
48+ return data
49+
50+ return self ._read_rest (data , size )
5851
52+ @decorate (concatenate_bytes )
53+ def _read_rest (self , data , size = - 1 ):
54+ # need an intermediary buffer
55+ out_len = len (data )
56+ while out_len < size :
57+ chunk = self ._reader .read (size - out_len )
58+ if chunk == b"" :
59+ raise EOFError ("Not enough data to read." )
60+ yield chunk
61+ out_len = out_len + len (chunk )
5962
6063class ZipCompressedReader (object ):
6164 """A buffer implementation reading zip compressed data from a source buffer and returning uncompressed data.
You can’t perform that action at this time.
0 commit comments