This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Readline not aborting line edition on sigint
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.5
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: martin.panter, memeplex
Priority: normal Keywords:

Created on 2016-04-30 14:45 by memeplex, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg264559 - (view) Author: Memeplex (memeplex) Date: 2016-04-30 14:45
Maybe this is just a bug in ipython but as it's closely related to http://bugs.python.org/issue23735 I'm reporting it here too, just in case.

-- My original report to bug-readline:

using readline with ipython 4.1.2 and the TkAgg (or GTK3Agg)
backend for matplotlib, I observed the following behavior:

1) open ipython in pylab mode (ipython --pylab or use the %pylab magic once inside the repl).

2) Type something.

3) Press Ctrl-C: line edition is not aborted as expected.

-- And this was Chet answer:

This is probably the result of the same signal handling issues as with
SIGWINCH that we discussed a little more than a year ago. Readline
catches the signal, sets a flag, and, when it's safe, resends it to the
calling application. It expects that if the calling application catches
SIGINT, it will take care of cleaning up the readline state. Sometimes
applications don't want to kill the current line on SIGINT.
Notice it doesn't happen with the Qt5Agg backend.
msg264617 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-05-02 04:21
What happens instead of aborting the line at step 3? Is Ctrl+C completely ignored, as if you didn’t press it?

Perhaps matplotlib is interfering with Python’s SIGINT handler and/or PyOS_InputHook().

Can you eliminate ipython from the equation? I.e. does the problem happen with the built-in Python interactive interpreter? Or with a simple script like the following:

import readline
import matplotlib  # Or whatever is needed to trigger it
while True:
    input("PROMPT ")
msg269605 - (view) Author: Memeplex (memeplex) Date: 2016-06-30 17:19
Martin: I can't reproduce the issue by just importing matplotlib with the TkAgg backend into a vanilla python repl. I will try to isolate the problem when I have some free time.
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71081
2021-12-05 23:29:00iritkatrielsetstatus: open -> closed
resolution: third party
stage: resolved
2016-06-30 17:19:57memeplexsetstatus: pending -> open

messages: + msg269605
2016-06-21 01:50:06martin.pantersetstatus: open -> pending
2016-05-02 04:21:20martin.pantersetnosy: + martin.panter
messages: + msg264617
2016-04-30 14:45:06memeplexcreate