]> granicus.if.org Git - python/commitdiff
bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812)
authorLovesh Harchandani <lovesh@users.noreply.github.com>
Fri, 27 Oct 2017 07:04:33 +0000 (09:04 +0200)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 27 Oct 2017 07:04:33 +0000 (08:04 +0100)
TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.

Lib/logging/handlers.py

index a815f033e60bcd1eb2369d2ca112d323524bdf4f..d1871acfa4ba594012971e6feb80fc7ef0576e94 100644 (file)
@@ -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