]> granicus.if.org Git - python/commitdiff
bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 19 Nov 2017 18:43:49 +0000 (10:43 -0800)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sun, 19 Nov 2017 18:43:49 +0000 (18:43 +0000)
TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.
(cherry picked from commit afad147b59fe84b12317f7340ddd2deeecb22321)

Lib/logging/handlers.py

index 2f934b330715633d8daf875fddf954754464fef1..daa71abd785bec0eb1d40d21c93b0b77c9359f15 100644 (file)
@@ -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