summaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/application
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-09-11 19:12:15 +0300
committerrobot-piglet <[email protected]>2025-09-11 19:43:09 +0300
commit91708f49a58e3c0a1a3cf0a60c268c2d5b474a3e (patch)
tree9dbcd5cd1811b171ca7636600287d72327ef98ec /contrib/python/prompt-toolkit/py3/prompt_toolkit/application
parentf4413504c29db8e1e7cce3a2103e89ecb4073271 (diff)
Intermediate changes
commit_hash:87ab6d7772f084decaa30c0cb439a3e0c000406e
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/application')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py36
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py2
2 files changed, 21 insertions, 17 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
index d93c24398ab..f27ada1a00b 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
@@ -1600,27 +1600,31 @@ def _restore_sigint_from_ctypes() -> Generator[None, None, None]:
try:
from ctypes import c_int, c_void_p, pythonapi
except ImportError:
- # Any of the above imports don't exist? Don't do anything here.
- yield
- return
-
- # PyOS_sighandler_t PyOS_getsig(int i)
- pythonapi.PyOS_getsig.restype = c_void_p
- pythonapi.PyOS_getsig.argtypes = (c_int,)
-
- # PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
- pythonapi.PyOS_setsig.restype = c_void_p
- pythonapi.PyOS_setsig.argtypes = (
- c_int,
- c_void_p,
- )
+ have_ctypes_signal = False
+ else:
+ # GraalPy has the functions, but they don't work
+ have_ctypes_signal = sys.implementation.name != "graalpy"
+
+ if have_ctypes_signal:
+ # PyOS_sighandler_t PyOS_getsig(int i)
+ pythonapi.PyOS_getsig.restype = c_void_p
+ pythonapi.PyOS_getsig.argtypes = (c_int,)
+
+ # PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
+ pythonapi.PyOS_setsig.restype = c_void_p
+ pythonapi.PyOS_setsig.argtypes = (
+ c_int,
+ c_void_p,
+ )
sigint = signal.getsignal(signal.SIGINT)
- sigint_os = pythonapi.PyOS_getsig(signal.SIGINT)
+ if have_ctypes_signal:
+ sigint_os = pythonapi.PyOS_getsig(signal.SIGINT)
try:
yield
finally:
if sigint is not None:
signal.signal(signal.SIGINT, sigint)
- pythonapi.PyOS_setsig(signal.SIGINT, sigint_os)
+ if have_ctypes_signal:
+ pythonapi.PyOS_setsig(signal.SIGINT, sigint_os)
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py
index 3f7eb4bd46c..f7032fe72a0 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py
@@ -149,7 +149,7 @@ def create_app_session(
# If no input/output is specified, fall back to the current input/output,
# 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
+ # because we don't want to accidentally 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