]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] bpo-45628: Check all parts of the suffix for an extension match. (GH-29310...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 29 Oct 2021 15:25:31 +0000 (08:25 -0700)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 15:25:31 +0000 (16:25 +0100)
Lib/logging/handlers.py

index 4dcbe4530fcfcccb9ccf9b9ea6af580bea7b89b4..4e8f0a8cc2f469fd97810ac7343f3e1bcf98eec7 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: