From b17db7994abb3611c2aa660bc45d3607dbaf9560 Mon Sep 17 00:00:00 2001 From: Korbinian Preisler Date: Wed, 6 Apr 2022 07:37:13 +0200 Subject: [PATCH] BUG: Fix formatWarning for filename without slash (#612) --- PyPDF2/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyPDF2/utils.py b/PyPDF2/utils.py index 2120c7021..fe9c1e455 100644 --- a/PyPDF2/utils.py +++ b/PyPDF2/utils.py @@ -66,7 +66,7 @@ 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 + file = filename.replace("/", "\\").rsplit("\\", 1)[-1] # find the file name return "%s: %s [%s:%s]\n" % (category.__name__, message, file, lineno)