From: Lovesh Harchandani Date: Fri, 27 Oct 2017 07:04:33 +0000 (+0200) Subject: bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) X-Git-Tag: v3.7.0a3~296 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=afad147b59fe84b12317f7340ddd2deeecb22321;p=python bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed. --- 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