Skip to content

Fix compatibility when SIGINT handler is installed by non-Python#1865

Merged
jonathanslenders merged 1 commit intoprompt-toolkit:masterfrom
quark-zju:patch-1
May 15, 2024
Merged

Fix compatibility when SIGINT handler is installed by non-Python#1865
jonathanslenders merged 1 commit intoprompt-toolkit:masterfrom
quark-zju:patch-1

Conversation

@quark-zju
Copy link
Contributor

When a native (Rust, C) program installs SIGINT handler and calls into Python, signal.getsignal can return None, which is not a valid value for the 2nd parameter of signal.signal. Fix it by checking None explicitly.

When a native (Rust, C) program installs SIGINT handler and calls into Python,
`signal.getsignal` can return `None`, which is not a valid value for the 2nd
parameter of `signal.signal`. Fix it by checking `None` explicitly.
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Apr 9, 2024
Summary:
Without this, prompt-toolkit (used by IPython) will crash at `_restore_sigint_from_ctypes`:

    sigint = signal.getsignal(signal.SIGINT)  # None, since the SIGINT handler is not installed by Python
    signal.signal(signal.SIGINT, sigint)      # TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

See prompt-toolkit/python-prompt-toolkit@6a24c99

Upstream fix: prompt-toolkit/python-prompt-toolkit#1865

Reviewed By: zzl0

Differential Revision: D55900919

fbshipit-source-id: 1a5a4fa79175fdbd0ea63e0ca4fbabe2138b6c25
@jonathanslenders
Copy link
Member

Thanks!

@jonathanslenders jonathanslenders merged commit 85079ad into prompt-toolkit:master May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants