Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load epubs from ZipExtFile #272

Open
ascendant512 opened this issue Dec 17, 2022 · 0 comments
Open

Can't load epubs from ZipExtFile #272

ascendant512 opened this issue Dec 17, 2022 · 0 comments

Comments

@ascendant512
Copy link

Hi,
I encountered a regression from 0.17.1 -> 0.18 in that the library crashes if it's fed a ZipExtFile object.
The crash is here:

if os.path.isdir(self.file_name):

File ".../venv/lib/python3.10/site-packages/ebooklib/epub.py", line 1700, in _load
    if os.path.isdir(self.file_name):
  File "/usr/lib/python-exec/python3.10/../../../lib/python3.10/genericpath.py", line 42, in isdir
    st = os.stat(s)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not ZipExtFile

To clarify, my script opens a zip file with zipfile.ZipFile in the standard library, and then opens .epub files inside the zip file with ZipFile.open()
You might be able to say it's a bug in os.stat.isdir() since it's definitely not a dir 😄. But, it would be nice if you could catch TypeError and then treat the input as a file and not a directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant