<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 """ Reads the given number of bytes from the given file and checks that the correct number of bytes could be read. """

        result = fd.read(nbytes)

        if (not result and nbytes > 0) or len(result) != nbytes:
            raise InvalidZoneinfoFile(
                "Expected {} bytes reading {}, "
                "but got {}".format(nbytes, fd.name, len(result) if result else 0)
            )

        if PY2:
            return bytearray(result)

        return result