aboutsummaryrefslogtreecommitdiffstats
path: root/epy.py
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2022-01-04 20:59:33 +0700
committerbenadha <benawiadha@gmail.com>2022-01-04 20:59:33 +0700
commitfe5ffbaa25417682148670110732d97d23bac7d5 (patch)
tree512d87de94cc015cdfbb62ba4bca052abb741a4b /epy.py
parent0b66f516bf5863730be84f6f07d74b5bd911cefc (diff)
downloadepy-fe5ffbaa25417682148670110732d97d23bac7d5.tar.gz
Remove bad try-except block
Diffstat (limited to 'epy.py')
-rwxr-xr-xepy.py21
1 files changed, 4 insertions, 17 deletions
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