[Python-checkins] bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466)

Vinay Sajip webhook-mailer at python.org
Sun Nov 19 13:43:52 EST 2017


https://github.com/python/cpython/commit/65dffe58dd062385024eacbe75a0fa59ec12a993
commit: 65dffe58dd062385024eacbe75a0fa59ec12a993
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: 2017-11-19T18:43:49Z
summary:

bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466)

TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.
(cherry picked from commit afad147b59fe84b12317f7340ddd2deeecb22321)

files:
M Lib/logging/handlers.py

diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 2f934b33071..daa71abd785 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
 



More information about the Python-checkins mailing list