Skip to content

Commit a55ebca

Browse files
committed
Update contrib/python/prompt-toolkit/py3 to 3.0.43
1 parent 511f212 commit a55ebca

File tree

26 files changed

+108
-56
lines changed

26 files changed

+108
-56
lines changed

contrib/python/prompt-toolkit/py3/.dist-info/METADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: prompt-toolkit
3-
Version: 3.0.41
3+
Version: 3.0.43
44
Summary: Library for building powerful interactive command lines in Python
55
Home-page: https://github.com/prompt-toolkit/python-prompt-toolkit
66
Author: Jonathan Slenders

contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .shortcuts import PromptSession, print_formatted_text, prompt
2828

2929
# Don't forget to update in `docs/conf.py`!
30-
__version__ = "3.0.41"
30+
__version__ = "3.0.43"
3131

3232
assert pep440.match(__version__)
3333

contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,16 +807,19 @@ def set_is_running() -> Iterator[None]:
807807
@contextmanager
808808
def set_handle_sigint(loop: AbstractEventLoop) -> Iterator[None]:
809809
if handle_sigint:
810-
loop.add_signal_handler(
811-
signal.SIGINT,
812-
lambda *_: loop.call_soon_threadsafe(
813-
self.key_processor.send_sigint
814-
),
815-
)
816-
try:
817-
yield
818-
finally:
819-
loop.remove_signal_handler(signal.SIGINT)
810+
with _restore_sigint_from_ctypes():
811+
# save sigint handlers (python and os level)
812+
# See: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576
813+
loop.add_signal_handler(
814+
signal.SIGINT,
815+
lambda *_: loop.call_soon_threadsafe(
816+
self.key_processor.send_sigint
817+
),
818+
)
819+
try:
820+
yield
821+
finally:
822+
loop.remove_signal_handler(signal.SIGINT)
820823
else:
821824
yield
822825

@@ -960,7 +963,8 @@ def run_in_thread() -> None:
960963
def _called_from_ipython() -> bool:
961964
try:
962965
return (
963-
"IPython/terminal/interactiveshell.py"
966+
sys.modules["IPython"].version_info < (8, 18, 0, "")
967+
and "IPython/terminal/interactiveshell.py"
964968
in sys._getframe(3).f_code.co_filename
965969
)
966970
except BaseException:
@@ -1545,7 +1549,7 @@ def _ignore(event: E) -> None:
15451549

15461550
@contextmanager
15471551
def attach_winch_signal_handler(
1548-
handler: Callable[[], None]
1552+
handler: Callable[[], None],
15491553
) -> Generator[None, None, None]:
15501554
"""
15511555
Attach the given callback as a WINCH signal handler within the context
@@ -1586,3 +1590,36 @@ def attach_winch_signal_handler(
15861590
previous_winch_handler._callback,
15871591
*previous_winch_handler._args,
15881592
)
1593+
1594+
1595+
@contextmanager
1596+
def _restore_sigint_from_ctypes() -> Generator[None, None, None]:
1597+
# The following functions are part of the stable ABI since python 3.2
1598+
# See: https://docs.python.org/3/c-api/sys.html#c.PyOS_getsig
1599+
# Inline import: these are not available on Pypy.
1600+
try:
1601+
from ctypes import c_int, c_void_p, pythonapi
1602+
except ImportError:
1603+
# Any of the above imports don't exist? Don't do anything here.
1604+
yield
1605+
return
1606+
1607+
# PyOS_sighandler_t PyOS_getsig(int i)
1608+
pythonapi.PyOS_getsig.restype = c_void_p
1609+
pythonapi.PyOS_getsig.argtypes = (c_int,)
1610+
1611+
# PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
1612+
pythonapi.PyOS_setsig.restype = c_void_p
1613+
pythonapi.PyOS_setsig.argtypes = (
1614+
c_int,
1615+
c_void_p,
1616+
)
1617+
1618+
sigint = signal.getsignal(signal.SIGINT)
1619+
sigint_os = pythonapi.PyOS_getsig(signal.SIGINT)
1620+
1621+
try:
1622+
yield
1623+
finally:
1624+
signal.signal(signal.SIGINT, sigint)
1625+
pythonapi.PyOS_setsig(signal.SIGINT, sigint_os)

contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from collections import deque
1616
from enum import Enum
1717
from functools import wraps
18-
from typing import Any, Awaitable, Callable, Coroutine, Iterable, TypeVar, cast
18+
from typing import Any, Callable, Coroutine, Iterable, TypeVar, cast
1919

2020
from .application.current import get_app
2121
from .application.run_in_terminal import run_in_terminal
@@ -1891,7 +1891,7 @@ def validate_and_handle(self) -> None:
18911891
self.reset()
18921892

18931893

1894-
_T = TypeVar("_T", bound=Callable[..., Awaitable[None]])
1894+
_T = TypeVar("_T", bound=Callable[..., Coroutine[Any, Any, None]])
18951895

18961896

18971897
def _only_one_at_a_time(coroutine: _T) -> _T:

contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
---------------------------------
3131
3232
- Syntax highlighting: We could use this for instance to give file names
33-
different colour.
33+
different color.
3434
- Parse the result: .. We can extract the file names and commands by using a
3535
regular expression with named groups.
3636
- Input validation: .. Don't accept anything that does not match this grammar.

contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import asyncio
77
import traceback
88
from asyncio import get_running_loop
9-
from typing import Any, Awaitable, Callable, TextIO, cast
9+
from typing import Any, Callable, Coroutine, TextIO, cast
1010

1111
import asyncssh
1212

@@ -21,7 +21,7 @@
2121
class PromptToolkitSSHSession(asyncssh.SSHServerSession): # type: ignore
2222
def __init__(
2323
self,
24-
interact: Callable[[PromptToolkitSSHSession], Awaitable[None]],
24+
interact: Callable[[PromptToolkitSSHSession], Coroutine[Any, Any, None]],
2525
*,
2626
enable_cpr: bool,
2727
) -> None:
@@ -162,7 +162,7 @@ async def interact(ssh_session: PromptToolkitSSHSession) -> None:
162162

163163
def __init__(
164164
self,
165-
interact: Callable[[PromptToolkitSSHSession], Awaitable[None]],
165+
interact: Callable[[PromptToolkitSSHSession], Coroutine[Any, Any, None]],
166166
*,
167167
enable_cpr: bool = True,
168168
) -> None:

contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import contextvars
88
import socket
99
from asyncio import get_running_loop
10-
from typing import Awaitable, Callable, TextIO, cast
10+
from typing import Any, Callable, Coroutine, TextIO, cast
1111

1212
from prompt_toolkit.application.current import create_app_session, get_app
1313
from prompt_toolkit.application.run_in_terminal import run_in_terminal
@@ -124,7 +124,7 @@ def __init__(
124124
self,
125125
conn: socket.socket,
126126
addr: tuple[str, int],
127-
interact: Callable[[TelnetConnection], Awaitable[None]],
127+
interact: Callable[[TelnetConnection], Coroutine[Any, Any, None]],
128128
server: TelnetServer,
129129
encoding: str,
130130
style: BaseStyle | None,
@@ -283,7 +283,9 @@ def __init__(
283283
self,
284284
host: str = "127.0.0.1",
285285
port: int = 23,
286-
interact: Callable[[TelnetConnection], Awaitable[None]] = _dummy_interact,
286+
interact: Callable[
287+
[TelnetConnection], Coroutine[Any, Any, None]
288+
] = _dummy_interact,
287289
encoding: str = "utf-8",
288290
style: BaseStyle | None = None,
289291
enable_cpr: bool = True,

contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def fileno(self) -> int:
6666

6767

6868
def new_eventloop_with_inputhook(
69-
inputhook: Callable[[InputHookContext], None]
69+
inputhook: Callable[[InputHookContext], None],
7070
) -> AbstractEventLoop:
7171
"""
7272
Create a new event loop with the given inputhook.
@@ -77,7 +77,7 @@ def new_eventloop_with_inputhook(
7777

7878

7979
def set_eventloop_with_inputhook(
80-
inputhook: Callable[[InputHookContext], None]
80+
inputhook: Callable[[InputHookContext], None],
8181
) -> AbstractEventLoop:
8282
"""
8383
Create a new event loop with the given inputhook, and activate it.

contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151

5252
# NOTE: `has_focus` below should *not* be `memoized`. It can reference any user
53-
# control. For instance, if we would contiously create new
53+
# control. For instance, if we would continuously create new
5454
# `PromptSession` instances, then previous instances won't be released,
5555
# because this memoize (which caches results in the global scope) will
5656
# still refer to each instance.

contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .base import (
1717
AnyFormattedText,
1818
FormattedText,
19+
OneStyleAndTextTuple,
1920
StyleAndTextTuples,
2021
Template,
2122
is_formatted_text,
@@ -35,6 +36,7 @@
3536
__all__ = [
3637
# Base.
3738
"AnyFormattedText",
39+
"OneStyleAndTextTuple",
3840
"to_formatted_text",
3941
"is_formatted_text",
4042
"Template",

0 commit comments

Comments
 (0)