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

formatWarning can crash #11

Open
farcepest opened this issue Oct 19, 2021 · 0 comments
Open

formatWarning can crash #11

farcepest opened this issue Oct 19, 2021 · 0 comments

Comments

@farcepest
Copy link

Apparently there are cases where PyPDF3 can generate a warning, but there's no filename to be found, which raises IndexError. In my case, this is happening while running coverage, during the collection phase.

File "/usr/lib/python3.8/ast.py", line 47, in parse
return compile(source, filename, mode, flags,
File "/usr/lib/python3.8/warnings.py", line 109, in _showwarnmsg
sw(msg.message, msg.category, msg.filename, msg.lineno,
File "/opt/python/lib/python3.8/site-packages/PyPDF3/pdf.py", line 1186, in _showwarning
file.write(formatWarning(message, category, filename, lineno, line))
File "/opt/python/lib/python3.8/site-packages/PyPDF3/utils.py", line 65, in formatWarning
file = filename.replace("/", "\").rsplit("\", 1)[1] # find the file name
IndexError: list index out of range

Python 3.8.10 (Ubuntu 20.04 LTS)

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