summaryrefslogtreecommitdiffstats
path: root/Lib/logging/handlers.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2012-03-13 12:15:09 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2012-03-13 12:15:09 (GMT)
commit0f15181d39a57382a218f8b98464b6a4881fa93a (patch)
treec9edc5e2cbe633db6a6ac070029149774ee94c61 /Lib/logging/handlers.py
parent4bd53b13c63cd026dbc99372cbd5bb7cc29b8b9d (diff)
parent27f48979cafa9b955fcb45eed273ccb72ba35201 (diff)
downloadcpython-0f15181d39a57382a218f8b98464b6a4881fa93a.zip
cpython-0f15181d39a57382a218f8b98464b6a4881fa93a.tar.gz
cpython-0f15181d39a57382a218f8b98464b6a4881fa93a.tar.bz2
Closes #14267: Merged fix from 3.2.
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r--Lib/logging/handlers.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index ee0096a..bebd79a 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -305,9 +305,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover:
if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
- newRolloverAt = newRolloverAt - 3600
+ addend = -3600
else: # DST bows out before next rollover, so we need to add an hour
- newRolloverAt = newRolloverAt + 3600
+ addend = 3600
+ newRolloverAt += addend
result = newRolloverAt
return result
@@ -358,11 +359,20 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self.stream.close()
self.stream = None
# get the time that this sequence started at and make it a TimeTuple
+ currentTime = int(time.time())
+ dstNow = time.localtime(currentTime)[-1]
t = self.rolloverAt - self.interval
if self.utc:
timeTuple = time.gmtime(t)
else:
timeTuple = time.localtime(t)
+ dstThen = timeTuple[-1]
+ if dstNow != dstThen:
+ if dstNow:
+ addend = 3600
+ else:
+ addend = -3600
+ timeTuple = time.localtime(t + addend)
dfn = self.rotation_filename(self.baseFilename + "." +
time.strftime(self.suffix, timeTuple))
if os.path.exists(dfn):
@@ -373,19 +383,18 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
os.remove(s)
self.mode = 'w'
self.stream = self._open()
- currentTime = int(time.time())
newRolloverAt = self.computeRollover(currentTime)
while newRolloverAt <= currentTime:
newRolloverAt = newRolloverAt + self.interval
#If DST changes and midnight or weekly rollover, adjust for this.
if (self.when == 'MIDNIGHT' or self.when.startswith('W')) and not self.utc:
- dstNow = time.localtime(currentTime)[-1]
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover:
if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
- newRolloverAt = newRolloverAt - 3600
+ addend = -3600
else: # DST bows out before next rollover, so we need to add an hour
- newRolloverAt = newRolloverAt + 3600
+ addend = 3600
+ newRolloverAt += addend
self.rolloverAt = newRolloverAt
class WatchedFileHandler(logging.FileHandler):