From cc2eefbb1728da0cb57846b5602df90d16375b78 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 7 Jan 2020 10:51:16 -0500 Subject: [PATCH] py3: fix creation of empty record with .txt format Metadata objects are unicode strings, but we tried to write the content directly to a .txt file opened in binary mode. --- src/calibre/ebooks/oeb/polish/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/create.py b/src/calibre/ebooks/oeb/polish/create.py index 46a0c0c5fe..2c86ed6e6c 100644 --- a/src/calibre/ebooks/oeb/polish/create.py +++ b/src/calibre/ebooks/oeb/polish/create.py @@ -42,7 +42,7 @@ def create_book(mi, path, fmt='epub', opf_name='metadata.opf', html_name='start. if fmt == 'txt': with open(path, 'wb') as f: if not mi.is_null('title'): - f.write(mi.title) + f.write(mi.title.encode('utf-8')) return if fmt == 'docx': from calibre.ebooks.conversion.plumber import Plumber