diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index c6b526a9c6c..9e1bec1c62b 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -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*")