[3.10] bpo-45628: Check all parts of the suffix for an extension match. (GH-29310) (GH-29314)
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 4dcbe45..4e8f0a8 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: