From a41fcfd3db7e20f596ba34b018914e704025ab6e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 23 Feb 2020 08:40:11 +0530 Subject: [PATCH] Fix #1864340 [calibredb list output to file is broken](https://bugs.launchpad.net/calibre/+bug/1864340) py3 apparently cant print newlines correctly when stdout is redirected to a file. Sigh. --- src/calibre/db/cli/cmd_list.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/db/cli/cmd_list.py b/src/calibre/db/cli/cmd_list.py index 041c48fb6f..a1afc96000 100644 --- a/src/calibre/db/cli/cmd_list.py +++ b/src/calibre/db/cli/cmd_list.py @@ -214,12 +214,12 @@ def do_list( lines = max(map(len, text)) for l in range(lines): for i, field in enumerate(text): - ft = text[i][l] if l < len(text[i]) else u'' + ft = text[i][l] if l < len(text[i]) else '' stdout.write(ft.encode('utf-8')) if i < len(text) - 1: - filler = (u'%*s' % (widths[i] - str_width(ft) - 1, u'')) + filler = ('%*s' % (widths[i] - str_width(ft) - 1, '')) stdout.write((filler + separator).encode('utf-8')) - print() + stdout.write(b'\n') def option_parser(get_parser, args):