From fe5ffbaa25417682148670110732d97d23bac7d5 Mon Sep 17 00:00:00 2001 From: benadha Date: Tue, 4 Jan 2022 20:59:33 +0700 Subject: Remove bad try-except block --- epy.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'epy.py') diff --git a/epy.py b/epy.py index ba14704..13ccb28 100755 --- a/epy.py +++ b/epy.py @@ -572,15 +572,10 @@ class Epub(Ebook): assert isinstance(self.file, zipfile.ZipFile) assert isinstance(content_path, str) - # using try-except block to catch + # use try-except block to catch # zlib.error: Error -3 while decompressing data: invalid distance too far back # caused by forking PROC_COUNTLETTERS - while True: - try: - content = self.file.open(content_path).read() - break - except: - continue + content = self.file.open(content_path).read() return content.decode("utf-8") def get_img_bytestr(self, impath: str) -> Tuple[str, bytes]: @@ -630,16 +625,8 @@ class Mobi(Epub): def get_raw_text(self, content_path: Union[str, ET.Element]) -> str: assert isinstance(content_path, str) - # using try-except block to catch - # zlib.error: Error -3 while decompressing data: invalid distance too far back - # caused by forking PROC_COUNTLETTERS - while True: - try: - with open(content_path) as f: - content = f.read() - break - except: - continue + with open(content_path) as f: + content = f.read() # return content.decode("utf-8") return content -- cgit