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

Commit

Permalink
Handle IndexError during formatWarning (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
farcepest committed Feb 3, 2022
1 parent 727d5a0 commit 5ed4677
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PyPDF3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def isBytes(b):

#custom implementation of warnings.formatwarning
def formatWarning(message, category, filename, lineno, line=None):
file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
try:
file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
except IndexError:
file = filename
return "%s: %s [%s:%s]\n" % (category.__name__, message, file, lineno)


Expand Down

0 comments on commit 5ed4677

Please sign in to comment.