def set_GENDER(self, player, line, target, value):
        """
        Attempt to change the gender of a thing.

        @param target: The thing to change the gender of.
        @param value: A string naming a gender on L{language.Gender}.
        """
        try:
            target.gender = getattr(language.Gender, value.upper())
        except __HOLE__:
            gender = {language.Gender.MALE: "male",
                      language.Gender.FEMALE: "female",
                      language.Gender.NEUTER: "neuter"}.get(target.gender)
            raise eimaginary.ActionFailure(events.ThatDoesntMakeSense(
                    actor=player.thing,
                    actorMessage=("Only male, female, and neuter are valid "
                                  "genders.  You remain ", gender, ".")))
        else:
            if player.thing is target:
                # XXX Why can't I do something with Noun to collapse these
                # cases?
                event = events.Success(
                    actor=player.thing,
                    actorMessage=(u"You set your gender to ", value, "."))
            else:
                event = events.Success(
                    actor=player.thing,
                    target=target,
                    actorMessage=("You set ", language.Noun(target).hisHer(),
                                  " gender to ", value, "."),
                    targetMessage=(player.thing, " set your gender to ",
                                   value, "."))
            event.broadcast()
dataset/ETHPy150Open twisted/imaginary/imaginary/action.py/Set.set_GENDER