Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 15, 2024

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
0 of 6 checks passed
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