]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] 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:24:41 +0000 (08:24 -0700)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 15:24:41 +0000 (16:24 +0100)
Lib/logging/handlers.py

index 7f1f10551c3040262dfd7b890fce7bf07f1f05e5..f8040c498c10de44aaa7f1f6fe7ac196ce89f930 100644 (file)
@@ -368,8 +368,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: