Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
History
=======
4.0.5
* enhancement: ``telnetlib3-client`` client shell now drains stdout.

4.0.4
* bugfix: servers using ``robot_check=True`` with ``encoding=False`` raised ``TypeError: buf
expected bytes, got <class 'str'>``. ``telnetlib3-server`` now also accepts ``--encoding=False``
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "telnetlib3"
version = "4.0.4" # Keep in sync with telnetlib3/accessories.py::get_version !
version = "4.0.5" # Keep in sync with telnetlib3/accessories.py::get_version !
description = " Python Telnet server and client CLI and Protocol library"
readme = "README.rst"
license = "ISC"
Expand Down
2 changes: 1 addition & 1 deletion telnetlib3/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

def get_version() -> str:
"""Return the current version of telnetlib3."""
return "4.0.4" # keep in sync with pyproject.toml !
return "4.0.5" # keep in sync with pyproject.toml !


def encoding_from_lang(lang: str) -> Optional[str]:
Expand Down
2 changes: 2 additions & 0 deletions telnetlib3/client_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ async def _raw_event_loop(
if raw_mode is None and want_repl():
state.reactivate_repl = True
stdout.write(out.encode())
if hasattr(stdout, 'drain'):
await stdout.drain()
_ts_file = telnet_writer.ctx.typescript_file
if _ts_file is not None:
_ts_file.write(out)
Expand Down
5 changes: 3 additions & 2 deletions telnetlib3/tests/test_client_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,7 @@ def at_eof(self) -> bool:
term = _make_term(writer)
term.check_auto_mode = lambda switched_to_raw, last_will_echo: None

stdout = mock.Mock()
stdout.write = mock.Mock()
stdout = mock.Mock(spec=["write"])

close_calls: list[str] = []

Expand Down Expand Up @@ -823,6 +822,7 @@ def at_eof(self) -> bool:

stdout = mock.Mock()
stdout.write = mock.Mock()
stdout.drain = mock.AsyncMock()

state = _RawLoopState(
switched_to_raw=True, last_will_echo=False, local_echo=False, linesep="\r\n"
Expand All @@ -839,6 +839,7 @@ def at_eof(self) -> bool:
want_repl=lambda: False,
)
assert "hello world" in ts_buf.getvalue()
stdout.drain.assert_called_once()


@pytest.mark.asyncio
Expand Down
Loading