From 2fc337d7798019872710aa4bee93c7f331a42e60 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Mar 2019 13:36:45 +0530 Subject: [PATCH] Dont use str(soup) --- src/calibre/ebooks/chm/reader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/chm/reader.py b/src/calibre/ebooks/chm/reader.py index fc65685273..0b4a1366d7 100644 --- a/src/calibre/ebooks/chm/reader.py +++ b/src/calibre/ebooks/chm/reader.py @@ -144,7 +144,7 @@ class CHMReader(CHMFile): import shutil shutil.copytree(output_dir, os.path.join(debug_dump, 'debug_dump')) for lpath in html_files: - with open(lpath, 'r+b') as f: + with lopen(lpath, 'r+b') as f: data = f.read() data = self._reformat(data, lpath) if isinstance(data, unicode_type): @@ -262,7 +262,7 @@ class CHMReader(CHMFile): pass # do not prettify, it would reformat the
 tags!
         try:
-            ans = str(soup)
+            ans = soup.decode_contents()
             self.re_encoded_files.add(os.path.abspath(htmlpath))
             return ans
         except RuntimeError: