calibredb list: Fix incorrect output when redirecting to file

py3 compat, caused by mix of text and binary output streams.
This commit is contained in:
Kovid Goyal 2021-01-09 06:08:51 +05:30
parent bd9f294318
commit 78a001b335
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -8,7 +8,6 @@ import os
import sys
from textwrap import TextWrapper
from calibre import prints
from calibre.db.cli.utils import str_width
from calibre.ebooks.metadata import authors_to_string
from calibre.utils.date import isoformat
@ -201,7 +200,7 @@ def do_list(
fields
)
with ColoredStream(sys.stdout, fg='green'):
prints(''.join(titles))
print(''.join(titles), flush=True)
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
linesep = as_bytes(os.linesep)