From b7e1b3bc250d5c72c3a8d74ab51f409a1793eb73 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Fri, 29 Oct 2021 13:25:30 +0100 Subject: [PATCH] bpo-45628: Check all parts of the suffix for an extension match. --- 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 b613bec1c42705..d42c48de5f0620 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -371,8 +371,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: