void-packages/srcpkgs/python3-ipython/patches/fix-race.patch

29 lines
1.2 KiB
Diff

See: https://github.com/ipython/ipython/issues/12164
diff --git a/IPython/utils/_process_posix.py b/IPython/utils/_process_posix.py
index 59b5c2389..e83da39c6 100644
--- a/IPython/utils/_process_posix.py
+++ b/IPython/utils/_process_posix.py
@@ -136,6 +136,7 @@ def system(self, cmd):
# record how far we've printed, so that next time we only print *new*
# content from the buffer.
out_size = 0
+ child = None
try:
# Since we're not really searching the buffer for text patterns, we
# can set pexpect's search window to be tiny and it won't matter.
@@ -158,6 +159,13 @@ def system(self, cmd):
# Update the pointer to what we've already printed
out_size = len(child.before)
except KeyboardInterrupt:
+
+ if child is None:
+ # the interrupt was received before pexpect.spawn()
+ # was done... recover as best as possible.
+ import signal
+ return -signal.SIGINT
+
# We need to send ^C to the process. The ascii code for '^C' is 3
# (the character is known as ETX for 'End of Text', see
# curses.ascii.ETX).