From 5b43aaac61ac94abe722bc98ae58468618f2f512 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 5 Jun 2024 06:45:14 +0200 Subject: Adding upstream version 3.0.46. Signed-off-by: Daniel Baumann --- src/prompt_toolkit/application/application.py | 3 ++- src/prompt_toolkit/application/current.py | 12 +++++++++--- src/prompt_toolkit/application/run_in_terminal.py | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/prompt_toolkit/application') diff --git a/src/prompt_toolkit/application/application.py b/src/prompt_toolkit/application/application.py index d463781..d93c243 100644 --- a/src/prompt_toolkit/application/application.py +++ b/src/prompt_toolkit/application/application.py @@ -1621,5 +1621,6 @@ def _restore_sigint_from_ctypes() -> Generator[None, None, None]: try: yield finally: - signal.signal(signal.SIGINT, sigint) + if sigint is not None: + signal.signal(signal.SIGINT, sigint) pythonapi.PyOS_setsig(signal.SIGINT, sigint_os) diff --git a/src/prompt_toolkit/application/current.py b/src/prompt_toolkit/application/current.py index 908141a..7e2cf48 100644 --- a/src/prompt_toolkit/application/current.py +++ b/src/prompt_toolkit/application/current.py @@ -147,11 +147,17 @@ def create_app_session( Like in the case of an Telnet/SSH server. """ # If no input/output is specified, fall back to the current input/output, - # whatever that is. + # if there was one that was set/created for the current session. + # (Note that we check `_input`/`_output` and not `input`/`output`. This is + # because we don't want to accidently create a new input/output objects + # here and store it in the "parent" `AppSession`. Especially, when + # combining pytest's `capsys` fixture and `create_app_session`, sys.stdin + # and sys.stderr are patched for every test, so we don't want to leak + # those outputs object across `AppSession`s.) if input is None: - input = get_app_session().input + input = get_app_session()._input if output is None: - output = get_app_session().output + output = get_app_session()._output # Create new `AppSession` and activate. session = AppSession(input=input, output=output) diff --git a/src/prompt_toolkit/application/run_in_terminal.py b/src/prompt_toolkit/application/run_in_terminal.py index 1e4da2d..18a3dad 100644 --- a/src/prompt_toolkit/application/run_in_terminal.py +++ b/src/prompt_toolkit/application/run_in_terminal.py @@ -1,6 +1,7 @@ """ Tools for running functions on the terminal above the current application or prompt. """ + from __future__ import annotations from asyncio import Future, ensure_future -- cgit v1.2.3