From a5aec9233fcba1a67a3b92ecee77ba8ed1539a0a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 17 Apr 2019 11:22:05 +0530 Subject: [PATCH] py3: Fix console_print --- src/calibre/srv/code.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/code.py b/src/calibre/srv/code.py index 13982860f3..ce41b7d122 100644 --- a/src/calibre/srv/code.py +++ b/src/calibre/srv/code.py @@ -68,7 +68,9 @@ def console_print(ctx, rd): raise HTTPForbidden('console printing is not allowed') with print_lock: print(rd.remote_addr, end=' ') - shutil.copyfileobj(rd.request_body_file, sys.stdout) + stdout = getattr(sys.stdout, 'buffer', sys.stdout) + shutil.copyfileobj(rd.request_body_file, stdout) + stdout.flush() return ''