Set all flags in ``flagset``, and clear all other flags.

def set_flagstate(flagset):
    """
    Set all flags in ``flagset``, and clear all other flags.

    """
    if not flagset <= _all_flags:
        raise ValueError("unrecognized flags in flagset")

    for f in flagset:
        set_flag(f)
    for f in _all_flags - flagset:
        clear_flag(f)