diff --git a/swift/container/sharder.py b/swift/container/sharder.py index 76dcc4172a..f1b3e80230 100644 --- a/swift/container/sharder.py +++ b/swift/container/sharder.py @@ -1527,10 +1527,11 @@ class ContainerSharder(ContainerReplicator): self._increment_stat('visited', 'success', statsd=True) else: self._increment_stat('visited', 'skipped') - except (Exception, Timeout) as error: + except (Exception, Timeout) as err: self._increment_stat('visited', 'failure', statsd=True) self.logger.exception( - 'Unhandled exception while processing %s: %s', path, error) + 'Unhandled exception while processing %s: %s', path, err) + error = err try: self._record_sharding_progress(broker, node, error) except (Exception, Timeout) as error: diff --git a/test/unit/obj/test_expirer.py b/test/unit/obj/test_expirer.py index 8df8936234..0f312813db 100644 --- a/test/unit/obj/test_expirer.py +++ b/test/unit/obj/test_expirer.py @@ -744,10 +744,9 @@ class TestObjectExpirer(TestCase): x.run_once = raise_exceptions x.run_forever() except SystemExit as err: - pass + self.assertEqual(str(err), 'exiting exception 2') finally: expirer.sleep = orig_sleep - self.assertEqual(str(err), 'exiting exception 2') self.assertEqual(x.logger.get_lines_for_level('error'), ['Unhandled exception: ']) log_args, log_kwargs = x.logger.log_dict['error'][0]