prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Call to signal.signal( ) in application.py fails due to signal.getsignal( ) returning None.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've been integrating ipython into an application for a number of years, but recently found a failure which is coming from prompt-toolkit. The issue on only in v3 of the code. The problem occurs at
prompt-toolkit/python-prompt-toolkit/application.py:727 (in the master)
signal.signal(signal.SIGWINCH, previous_winch_handler)
previous_winch_handler was assigned at line 691.
previous_winch_handler = signal.getsignal(signal.SIGWINCH)
This call returned None, and then the call on line 727 fails, since None is not an acceptable value for signal.signal().
Just prior to invoking the Python interpreter in my C++ application, I use signal( SIGWINCH, SIG_DFL ) to remove any installed signal handler from the C++ code. I also tried SIG_IGN, but to no avail, getsignal() still returns None. One workaround was to execute the following in my Python code before initializing IPython, and subsequently calling prompt-toolkit.
signal.signal( signal.SIGWINCH, signal.SIG_DFL )
So my question is; should the prompt-toolkit code account for the fact that getsignal() could return None? Or is there something better that I should do in my application? Or is my current workaround the way forward?
Regards,
John
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in python-prompt-toolkit/application.py around lines 691 and 727, tracing how SIGWINCH handlers are saved and restored. Reproduce the embedded-application case described here, then verify that the chosen handling accepts the reported getsignal() result without breaking normal signal restoration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100