'DEPRECATED since IPython 5.0
Set PyOS_InputHook to callback and return the previous one.'

def set_inputhook(self, callback):

    ignore_CTRL_C()
    self._callback = callback
    self._callback_pyfunctype = self.PYFUNC(callback)
    pyos_inputhook_ptr = self.get_pyos_inputhook()
    original = self.get_pyos_inputhook_as_func()
    pyos_inputhook_ptr.value = ctypes.cast(self._callback_pyfunctype, ctypes.c_void_p).value
    self._installed = True
    return original
