From 65dffe58dd062385024eacbe75a0fa59ec12a993 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 19 Nov 2017 10:43:49 -0800 Subject: [PATCH] bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466) TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed. (cherry picked from commit afad147b59fe84b12317f7340ddd2deeecb22321) --- 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 2f934b33071563..daa71abd785bec 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -356,10 +356,10 @@ def getFilesToDelete(self): 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