bpo-45628: Check all parts of the suffix for an extension match. (GH-29310)

This commit is contained in:
Vinay Sajip 2021-10-29 14:40:37 +01:00 committed by GitHub
parent 7bddd96982
commit 8a77f59de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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: