|
1 | 1 | diff --git a/prompt_toolkit/application/application.py b/prompt_toolkit/application/application.py
|
2 |
| -index d463781..c92b492 100644 |
| 2 | +index d93c243..ed4a57e 100644 |
3 | 3 | --- a/prompt_toolkit/application/application.py
|
4 | 4 | +++ b/prompt_toolkit/application/application.py
|
5 |
| -@@ -1597,29 +1597,31 @@ def _restore_sigint_from_ctypes() -> Generator[None, None, None]: |
| 5 | +@@ -1594,6 +1594,15 @@ def attach_winch_signal_handler( |
| 6 | + |
| 7 | + @contextmanager |
| 8 | + def _restore_sigint_from_ctypes() -> Generator[None, None, None]: |
| 9 | ++ import sys |
| 10 | ++ if sys.implementation.name == 'graalpy': |
| 11 | ++ sigint = signal.getsignal(signal.SIGINT) |
| 12 | ++ try: |
| 13 | ++ yield |
| 14 | ++ finally: |
| 15 | ++ if sigint is not None: |
| 16 | ++ signal.signal(signal.SIGINT, sigint) |
| 17 | ++ return |
6 | 18 | # The following functions are part of the stable ABI since python 3.2
|
7 | 19 | # See: https://docs.python.org/3/c-api/sys.html#c.PyOS_getsig
|
8 | 20 | # Inline import: these are not available on Pypy.
|
9 |
| -- try: |
10 |
| -- from ctypes import c_int, c_void_p, pythonapi |
11 |
| -- except ImportError: |
12 |
| -- # Any of the above imports don't exist? Don't do anything here. |
13 |
| -- yield |
14 |
| -- return |
15 |
| - |
16 |
| -- # PyOS_sighandler_t PyOS_getsig(int i) |
17 |
| -- pythonapi.PyOS_getsig.restype = c_void_p |
18 |
| -- pythonapi.PyOS_getsig.argtypes = (c_int,) |
19 |
| -+ # GraalPy change: avoid PyOS_getsig |
20 |
| -+ # try: |
21 |
| -+ # from ctypes import c_int, c_void_p, pythonapi |
22 |
| -+ # except ImportError: |
23 |
| -+ # # Any of the above imports don't exist? Don't do anything here. |
24 |
| -+ # yield |
25 |
| -+ # return |
26 |
| - |
27 |
| -- # PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h) |
28 |
| -- pythonapi.PyOS_setsig.restype = c_void_p |
29 |
| -- pythonapi.PyOS_setsig.argtypes = ( |
30 |
| -- c_int, |
31 |
| -- c_void_p, |
32 |
| -- ) |
33 |
| -+ # # PyOS_sighandler_t PyOS_getsig(int i) |
34 |
| -+ # pythonapi.PyOS_getsig.restype = c_void_p |
35 |
| -+ # pythonapi.PyOS_getsig.argtypes = (c_int,) |
36 |
| -+ |
37 |
| -+ # # PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h) |
38 |
| -+ # pythonapi.PyOS_setsig.restype = c_void_p |
39 |
| -+ # pythonapi.PyOS_setsig.argtypes = ( |
40 |
| -+ # c_int, |
41 |
| -+ # c_void_p, |
42 |
| -+ # ) |
43 |
| - |
44 |
| - sigint = signal.getsignal(signal.SIGINT) |
45 |
| -- sigint_os = pythonapi.PyOS_getsig(signal.SIGINT) |
46 |
| -+ # sigint_os = pythonapi.PyOS_getsig(signal.SIGINT) |
47 |
| - |
48 |
| - try: |
49 |
| - yield |
50 |
| - finally: |
51 |
| - signal.signal(signal.SIGINT, sigint) |
52 |
| -- pythonapi.PyOS_setsig(signal.SIGINT, sigint_os) |
53 |
| -+ # pythonapi.PyOS_setsig(signal.SIGINT, sigint_os) |
0 commit comments