From cd13fbfe27a45c7cdb2f98de279bf77b94526c05 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 12 Mar 2024 19:08:40 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/html/input.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py index 915dd042a4..7b67ad15cd 100644 --- a/src/calibre/ebooks/html/input.py +++ b/src/calibre/ebooks/html/input.py @@ -108,11 +108,10 @@ class HTMLFile: self.links = [] try: - f = case_ignoring_open_file(self.path, 'rb') if correct_case_mismatches else open(self.path, 'rb') - self.path = f.name - self.base = os.path.dirname(self.path) - self.title = os.path.splitext(os.path.basename(self.path))[0] - with f: + with (case_ignoring_open_file if correct_case_mismatches else open)(self.path, 'rb') as f: + self.path = f.name + self.base = os.path.dirname(self.path) + self.title = os.path.splitext(os.path.basename(self.path))[0] src = header = f.read(4096) encoding = detect_xml_encoding(src)[1] if encoding: