From 8ab66245ff0020b41deb39ec2e7ccf1eca0a8a38 Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Wed, 16 May 2018 17:35:31 +0200 Subject: [PATCH] More precise exception handling In python2 OSError and IOError are different for no good reason, in python3 IOError is an alias for OSError. --- tisbackup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tisbackup.py b/tisbackup.py index 35a3a6b..25119ca 100755 --- a/tisbackup.py +++ b/tisbackup.py @@ -374,7 +374,7 @@ def main(): hdlr = logging.FileHandler(os.path.join(log_dir,'tisbackup_%s.log' % (backup_start_date))) hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) logger.addHandler(hdlr) - except Exception, e: + except IOError, e: if action == 'cleanup' and e.errno == errno.ENOSPC: logger.warning("No space left on device, disabling file logging.") else: