summaryrefslogtreecommitdiffstats
path: root/Lib/logging/handlers.py
diff options
context:
space:
mode:
authorLovesh Harchandani <lovesh@users.noreply.github.com>2017-10-27 07:04:33 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-10-27 07:04:33 (GMT)
commitafad147b59fe84b12317f7340ddd2deeecb22321 (patch)
treec8baf4e9a25c1417c6253b081ae22880b896faf6 /Lib/logging/handlers.py
parentd609b0c24ebdb748cabcc6c062dfc86f9000e6c4 (diff)
downloadcpython-afad147b59fe84b12317f7340ddd2deeecb22321.zip
cpython-afad147b59fe84b12317f7340ddd2deeecb22321.tar.gz
cpython-afad147b59fe84b12317f7340ddd2deeecb22321.tar.bz2
bpo-30989: Sort in TimedRotatingFileHandler only when needed. (GH-2812)
TimedRotatingFileHandler.getFilesToDelete() now sorts only when needed.
Diffstat (limited to 'Lib/logging/handlers.py')
-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 a815f03..d1871ac 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