From c0cb42a0d47e94eca739b960bffb2b0bbcd38c69 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Fri, 29 Oct 2021 14:40:37 +0100 Subject: [PATCH] bpo-45628: Check all parts of the suffix for an extension match. (GH-29310) (cherry picked from commit 8a77f59de51f1fd6062f0fefe73ee3059d714144) Co-authored-by: Vinay Sajip --- Lib/logging/handlers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 7f1f10551c3040..f8040c498c10de 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -368,8 +368,13 @@ def getFilesToDelete(self): for fileName in fileNames: if fileName[:plen] == prefix: suffix = fileName[plen:] - if self.extMatch.match(suffix): - result.append(os.path.join(dirName, fileName)) + # See bpo-45628: The date/time suffix could be anywhere in the + # filename + parts = suffix.split('.') + for part in parts: + if self.extMatch.match(part): + result.append(os.path.join(dirName, fileName)) + break if len(result) < self.backupCount: result = [] else: