Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

formatWarning can crash #11

Description

@farcepest

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions