From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] python3-prompt_toolkit: don't handle sigint
Date: Thu, 24 Feb 2022 21:59:11 +0100 [thread overview]
Message-ID: <20220224205911.ADDtmoXuMIkrJUKCGenlsTsazW4dmmDCSwVac9RTvIk@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-35730@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]
There is an updated pull request by tornaria against master on the void-packages repository
https://github.com/tornaria/void-packages prompt_toolkit
https://github.com/void-linux/void-packages/pull/35730
python3-prompt_toolkit: don't handle sigint
Fixes #35712
See also: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **YES**
<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/35730.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-prompt_toolkit-35730.patch --]
[-- Type: text/x-diff, Size: 3644 bytes --]
From 7de146d4a03fac4adae8c2e10397ab61274e9611 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 21 Feb 2022 10:52:16 -0300
Subject: [PATCH] python3-prompt_toolkit: restore sigint handlers
Fixes #35712
See also: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576
---
.../patches/restore-sigint-handler.patch | 57 +++++++++++++++++++
srcpkgs/python3-prompt_toolkit/template | 2 +-
2 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 srcpkgs/python3-prompt_toolkit/patches/restore-sigint-handler.patch
diff --git a/srcpkgs/python3-prompt_toolkit/patches/restore-sigint-handler.patch b/srcpkgs/python3-prompt_toolkit/patches/restore-sigint-handler.patch
new file mode 100644
index 000000000000..9e0fbdbfe03f
--- /dev/null
+++ b/srcpkgs/python3-prompt_toolkit/patches/restore-sigint-handler.patch
@@ -0,0 +1,57 @@
+When setting a sigint handler, save and restore the previous handler,
+since add_signal_handler and remove_signal_handler don't.
+
+Use cysignals if available so that the os-level handlers (struct
+sigaction) are saved as well. If cysignals is not available, fallback
+to saving only the python handlers.
+
+See:
+ - https://github.com/void-linux/void-packages/issues/35712
+ - https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576
+ - https://trac.sagemath.org/ticket/33360#comment:3
+
+--- a/prompt_toolkit/application/application.py 2022-02-11 05:06:37.000000000 -0300
++++ b/prompt_toolkit/application/application.py 2022-02-22 15:31:02.248681343 -0300
+@@ -98,6 +98,10 @@
+ except ImportError:
+ import prompt_toolkit.eventloop.dummy_contextvars as contextvars # type: ignore
+
++try:
++ from cysignals import pysignals
++except ImportError:
++ from . import dummy_pysignals as pysignals
+
+ __all__ = [
+ "Application",
+@@ -805,6 +809,9 @@
+ loop = get_event_loop()
+
+ if handle_sigint:
++ # save sigint handlers
++ _sigint = signal.getsignal(signal.SIGINT)
++ _sigint_os = pysignals.getossignal(signal.SIGINT)
+ loop.add_signal_handler(
+ signal.SIGINT,
+ lambda *_: loop.call_soon_threadsafe(
+@@ -843,6 +850,8 @@
+
+ if handle_sigint:
+ loop.remove_signal_handler(signal.SIGINT)
++ # restore python and os-level signal handlers
++ pysignals.setsignal(signal.SIGINT, _sigint, _sigint_os)
+
+ # Reset slow_callback_duration.
+ loop.slow_callback_duration = original_slow_callback_duration
+--- a/prompt_toolkit/application/dummy_pysignals.py 1969-12-31 21:00:00.000000000 -0300
++++ b/prompt_toolkit/application/dummy_pysignals.py 2022-02-22 15:31:26.432386296 -0300
+@@ -0,0 +1,10 @@
++# fallback in case cysignals is not available
++# these functions don't save the os level handlers
++
++import signal
++
++def getossignal(sig):
++ return None
++
++def setsignal(sig, action, osaction=None):
++ return signal.signal(sig, action)
diff --git a/srcpkgs/python3-prompt_toolkit/template b/srcpkgs/python3-prompt_toolkit/template
index 0d625dc249fa..26bcb33e82bc 100644
--- a/srcpkgs/python3-prompt_toolkit/template
+++ b/srcpkgs/python3-prompt_toolkit/template
@@ -1,7 +1,7 @@
# Template file for 'python3-prompt_toolkit'
pkgname=python3-prompt_toolkit
version=3.0.28
-revision=1
+revision=2
wrksrc="prompt_toolkit-${version}"
build_style=python3-module
hostmakedepends="python3-setuptools"
next prev parent reply other threads:[~2022-02-24 20:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 14:03 [PR PATCH] " tornaria
2022-02-21 14:11 ` ahesford
2022-02-21 14:11 ` ahesford
2022-02-21 14:35 ` tornaria
2022-02-24 20:59 ` tornaria [this message]
2022-02-24 21:01 ` tornaria
2022-02-25 15:53 ` ahesford
2022-02-25 21:46 ` tornaria
2022-02-25 22:11 ` ahesford
2022-02-27 18:19 ` tornaria
2022-02-27 21:48 ` ahesford
2022-02-27 21:49 ` ahesford
2022-02-27 21:49 ` ahesford
2022-02-28 1:35 ` [PR PATCH] [Updated] " tornaria
2022-02-28 1:59 ` tornaria
2022-02-28 2:25 ` [PR PATCH] [Merged]: " ahesford
2022-02-28 2:28 ` ahesford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220224205911.ADDtmoXuMIkrJUKCGenlsTsazW4dmmDCSwVac9RTvIk@z \
--to=tornaria@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).