def checkread(stream, n):
    """Read exactly *n* bytes from *stream*.

    A ParseError is raised if less than *n* bytes are available.

    """
    data = stream.read(n)
    if len(data) < n:
        raise ValueError('unexpected end of file')
    return data
