summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-19 18:43:49 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-11-19 18:43:49 (GMT)
commit65dffe58dd062385024eacbe75a0fa59ec12a993 (patch)
tree55e79e5e87445c1641ea074070234162d17bb56a
parent80baec58f5019977c2f46f07ab0a4362c121127f (diff)
downloadcpython-65dffe58dd062385024eacbe75a0fa59ec12a993.zip
cpython-65dffe58dd062385024eacbe75a0fa59ec12a993.tar.gz
cpython-65dffe58dd062385024eacbe75a0fa59ec12a993.tar.bz2
bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812) (GH-4466)
TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed. (cherry picked from commit afad147b59fe84b12317f7340ddd2deeecb22321)
-rw-r--r--Lib/logging/handlers.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 2f934b3..daa71ab 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