From afad147b59fe84b12317f7340ddd2deeecb22321 Mon Sep 17 00:00:00 2001 From: Lovesh Harchandani Date: Fri, 27 Oct 2017 09:04:33 +0200 Subject: [PATCH] bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed. --- Lib/logging/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index a815f033e6..d1871acfa4 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -353,10 +353,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 -- 2.50.1