def read(self, length=None):
        """Read the given amount of bytes."""
        if length is None:
            return self.reader.read()

        result = self.reader.read(length)
        if len(result) != length:
            raise BufferError(
                'No more data left to read (need {}, got {}: {}); last read {}'
                .format(length, len(result), repr(result), repr(self._last))
            )

        self._last = result
        return result
def read ( self , length = None ) : if length is None : return self . reader . read ( ) result = self . reader . read ( length ) if len ( result ) != length : raise BufferError ( 'No more data left to read (need {}, got {}: {}); last read {}' . format ( length , len ( result ) , repr ( result ) , repr ( self . _last ) ) ) self . _last = result return result
Read the given amount of bytes.