'Read up to len(b) bytes into b.
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is \'interactive\'.
Returns the number of bytes read (0 for EOF).
Raises BlockingIOError if the underlying raw stream has no
data at the moment.'

def readinto(self, b):

    data = self.read(len(b))
    n = len(data)
    try:
        b[:n] = data
    except TypeError as err:
        import array
        if (not isinstance(b, array.array)):
            raise err
        b[:n] = array.array(u'b', data)
    return n
