mirror of
https://github.com/python/cpython
synced 2026-09-29 09:20:29 +03:00
Exceptions raised during renaming in rotating file handlers are now passed to handleError (except for SystemExit and KeyboardInterrupt, which are re-raised).
This commit is contained in:
parent
d952041dc7
commit
e928977b80
1 changed files with 12 additions and 2 deletions
|
|
@ -126,7 +126,12 @@ class RotatingFileHandler(BaseRotatingHandler):
|
|||
dfn = self.baseFilename + ".1"
|
||||
if os.path.exists(dfn):
|
||||
os.remove(dfn)
|
||||
os.rename(self.baseFilename, dfn)
|
||||
try:
|
||||
os.rename(self.baseFilename, dfn)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pass
|
||||
#print "%s -> %s" % (self.baseFilename, dfn)
|
||||
if self.encoding:
|
||||
self.stream = codecs.open(self.baseFilename, 'w', self.encoding)
|
||||
|
|
@ -270,7 +275,12 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
|
|||
dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
|
||||
if os.path.exists(dfn):
|
||||
os.remove(dfn)
|
||||
os.rename(self.baseFilename, dfn)
|
||||
try:
|
||||
os.rename(self.baseFilename, dfn)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pass
|
||||
if self.backupCount > 0:
|
||||
# find the oldest log file and delete it
|
||||
s = glob.glob(self.baseFilename + ".20*")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue