From 04eceae7bee460b086152eda3bfac2f85475abc8 Mon Sep 17 00:00:00 2001 From: Korbinian Preisler Date: Mon, 29 Mar 2021 14:08:22 +0200 Subject: [PATCH] Fix formatWarning for filename without slash --- 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)