'Return the next size number of bytes from the stream.
If size is not defined, return all bytes of the stream
up to EOF.'

def read(self, size=None):

    if (size is None):
        t = []
        while True:
            buf = self._read(self.bufsize)
            if (not buf):
                break
            t.append(buf)
        buf = ''.join(t)
    else:
        buf = self._read(size)
    self.pos += len(buf)
    return buf
