aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLovesh Harchandani <lovesh@users.noreply.github.com>2017-10-27 09:04:33 +0200
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-10-27 08:04:33 +0100
commitafad147b59fe84b12317f7340ddd2deeecb22321 (patch)
treec8baf4e9a25c1417c6253b081ae22880b896faf6 /Lib/logging
parentbpo-31053: Remove redundant 'venv' argument in venv example (GH-2907) (diff)
downloadcpython-afad147b59fe84b12317f7340ddd2deeecb22321.tar.gz
cpython-afad147b59fe84b12317f7340ddd2deeecb22321.tar.bz2
cpython-afad147b59fe84b12317f7340ddd2deeecb22321.zip
bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812)
TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.
Diffstat (limited to 'Lib/logging')
-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 a815f033e60..d1871acfa4b 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -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