From 4775fc780c98bca3ac5279b2a057cf0f1b4d7502 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Apr 2019 14:07:04 +0530 Subject: [PATCH] py3: Fix prints() --- src/calibre/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 7fc64c0e5f..f259e9819c 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -158,9 +158,13 @@ def prints(*args, **kwargs): ''' file = kwargs.get('file', sys.stdout) file = getattr(file, 'buffer', file) - sep = bytes(kwargs.get('sep', ' ')) - end = bytes(kwargs.get('end', '\n')) enc = 'utf-8' if 'CALIBRE_WORKER' in os.environ else preferred_encoding + sep = kwargs.get('sep', ' ') + if not isinstance(sep, bytes): + sep = sep.encode(enc) + end = kwargs.get('end', '\n') + if not isinstance(end, bytes): + end = end.encode(enc) safe_encode = kwargs.get('safe_encode', False) count = 0 for i, arg in enumerate(args):