<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def unpack(self, fmt):
 """ unpacks the given fmt from the underlying stream and returns the results. Will raise an UnpackException if there is not enough data to satisfy the fmt """


        sfmt = compile_struct(fmt)
        size = sfmt.size

        if not self.data:
            raise UnpackException(fmt, size, 0)

        buff = self.data.read(size)
        if len(buff) < size:
            raise UnpackException(fmt, size, len(buff))

        return sfmt.unpack(buff)