diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 2f934b33071..daa71abd785 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -356,10 +356,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler): suffix = fileName[plen:] if self.extMatch.match(suffix): result.append(os.path.join(dirName, fileName)) - result.sort() if len(result) < self.backupCount: result = [] else: + result.sort() result = result[:len(result) - self.backupCount] return result