mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
authplugin-example.py: Flush stderr.
Python 3's stderr was fully-buffered when non-interactive, unlike
Python 2 and more or less everything else, until 3.9 in 2020(!):
https://bugs.python.org/issue13601
(It would be less faff to sys.stderr.reconfigure(line_buffering=True)
at the start, but that was only added in 3.7, whereas the 'flush'
argument to print() dates back to 3.3, so I chose that to minimise
the risk of version dependencies getting in the way of using this as
a working example.)
(cherry picked from commit 329a4cdd79
)
This commit is contained in:
parent
5a50288718
commit
fe11c1e498
@ -136,7 +136,8 @@ def protocol():
|
|||||||
hostname = rd_string_utf8(msg)
|
hostname = rd_string_utf8(msg)
|
||||||
port = rd_uint32(msg)
|
port = rd_uint32(msg)
|
||||||
username = rd_string_utf8(msg)
|
username = rd_string_utf8(msg)
|
||||||
print(f"Got hostname {hostname!r}, port {port!r}", file=sys.stderr)
|
print(f"Got hostname {hostname!r}, port {port!r}", file=sys.stderr,
|
||||||
|
flush=True)
|
||||||
|
|
||||||
# Decide which protocol version we're speaking.
|
# Decide which protocol version we're speaking.
|
||||||
version = min(their_version, our_max_version)
|
version = min(their_version, our_max_version)
|
||||||
@ -281,7 +282,7 @@ def protocol():
|
|||||||
|
|
||||||
# Demonstration write to stderr, to prove that it shows up in PuTTY's
|
# Demonstration write to stderr, to prove that it shows up in PuTTY's
|
||||||
# Event Log.
|
# Event Log.
|
||||||
print("Hello from test plugin's stderr", file=sys.stderr)
|
print("Hello from test plugin's stderr", file=sys.stderr, flush=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
protocol()
|
protocol()
|
||||||
|
Loading…
Reference in New Issue
Block a user