From 1d35b786015f02406e5e82260334ca5ef92fe0a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Feb 2020 16:54:57 +0530 Subject: [PATCH] py3: Fix calibredb list Fixes #1863470 [[python3] calibredb list fails](https://bugs.launchpad.net/calibre/+bug/1863470) --- src/calibre/db/cli/cmd_list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/cli/cmd_list.py b/src/calibre/db/cli/cmd_list.py index ecd0143af6..041c48fb6f 100644 --- a/src/calibre/db/cli/cmd_list.py +++ b/src/calibre/db/cli/cmd_list.py @@ -203,6 +203,7 @@ def do_list( ) with ColoredStream(sys.stdout, fg='green'): prints(''.join(titles)) + stdout = getattr(sys.stdout, 'buffer', sys.stdout) wrappers = [TextWrapper(x - 1).wrap if x > 1 else lambda y: y for x in widths] @@ -214,10 +215,10 @@ def do_list( for l in range(lines): for i, field in enumerate(text): ft = text[i][l] if l < len(text[i]) else u'' - sys.stdout.write(ft.encode('utf-8')) + stdout.write(ft.encode('utf-8')) if i < len(text) - 1: filler = (u'%*s' % (widths[i] - str_width(ft) - 1, u'')) - sys.stdout.write((filler + separator).encode('utf-8')) + stdout.write((filler + separator).encode('utf-8')) print()