dev-lang/python: Add patch for spurious unhandled SIGINTs
Upstream bugs:
https://bugs.gentoo.org/678410
https://bugs.python.org/issue23395
Sometimes portage (via python) dies with a TypeError due to SIGINT not
being handled in some cases.
The patches were taken from the python.org bug and manually applied to
our versions of Python.
BUG=chromium:991683
TEST=`emerge dev-lang/python:3.6`
TEST=`emerge dev-lang/python:2.7`
Change-Id: Ic76e7badfe250bfb8e3099ac053a6add0a130345
Reviewed-on: https://chromium-review.googlesource.com/1742565
Tested-by: Chris McDonald <cjmcdonald@chromium.org>
Commit-Ready: Chris McDonald <cjmcdonald@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/dev-lang/python/files/python-2.7.15-sigint-handler.patch b/dev-lang/python/files/python-2.7.15-sigint-handler.patch
new file mode 100644
index 0000000..a8642c9
--- /dev/null
+++ b/dev-lang/python/files/python-2.7.15-sigint-handler.patch
@@ -0,0 +1,23 @@
+Upstream bugs:
+https://bugs.gentoo.org/678410
+https://bugs.python.org/issue23395
+
+This patch fixes some spurious exceptions caused by interrupts
+that don't have a handler registered in some situations.
+
+diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
+index ef70d10..a4fb44e 100644
+--- a/Modules/signalmodule.c
++++ b/Modules/signalmodule.c
+@@ -956,7 +956,10 @@ PyErr_CheckSignals(void)
+ void
+ PyErr_SetInterrupt(void)
+ {
+- trip_signal(SIGINT);
++ if ((Handlers[SIGINT].func != IgnoreHandler) &&
++ (Handlers[SIGINT].func != DefaultHandler)) {
++ trip_signal(SIGINT);
++ }
+ }
+
+ void