From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 19 Nov 2017 18:43:49 +0000 (-0800) Subject: bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466) X-Git-Tag: v3.6.4rc1~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65dffe58dd062385024eacbe75a0fa59ec12a993;p=python bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466) TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed. (cherry picked from commit afad147b59fe84b12317f7340ddd2deeecb22321) --- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 2f934b3307..daa71abd78 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