]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45628: Check all parts of the suffix for an extension match. (GH-29310)
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 29 Oct 2021 13:40:37 +0000 (14:40 +0100)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 13:40:37 +0000 (14:40 +0100)
Lib/logging/handlers.py

index b613bec1c42705f00f4cea0398fb850224e7cad4..d42c48de5f06205909701522a7b59296e62ca916 100644 (file)
@@ -371,8 +371,13 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
         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: