From a031f072146548ccf2d8c75944d0f1d62b6b6878 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Apr 2021 22:09:46 +0530 Subject: [PATCH] CHM Input: Fix a regression in calibre 5.0 that broke opening of some files that dont specify a character encoding. Fixes #1922503 [E-book viewer: error opening a *.chm file](https://bugs.launchpad.net/calibre/+bug/1922503) py3 compat --- src/calibre/ebooks/chm/reader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/ebooks/chm/reader.py b/src/calibre/ebooks/chm/reader.py index 1139777787..e4f9ecf86e 100644 --- a/src/calibre/ebooks/chm/reader.py +++ b/src/calibre/ebooks/chm/reader.py @@ -77,6 +77,8 @@ class CHMReader(CHMFile): ans = lcid[0] if ans: try: + if isinstance(ans, bytes): + ans = ans.decode('ascii') codecs.lookup(ans) except Exception: ans = None