'Change a registered file object monitored events and data.'

def modify(self, fileobj, events, data=None):

    try:
        key = self._fd_to_key[self._fileobj_lookup(fileobj)]
    except KeyError:
        raise KeyError('{0!r}    is    not    registered'.format(fileobj))
    if (events != key.events):
        self.unregister(fileobj)
        key = self.register(fileobj, events, data)
    elif (data != key.data):
        key = key._replace(data=data)
        self._fd_to_key[key.fd] = key
    return key
