Py3: Fix two unbound variables

In Python 3, the scope of errors in "try/except" clauses is more limited than in
Python 2.

Change-Id: I600145cd462b0f20740c290ecc4041fb4de02b33
This commit is contained in:
Cyril Roelandt 2018-12-03 13:59:33 +01:00
parent c9dd7efb81
commit 39f6d5a5fd
2 changed files with 4 additions and 4 deletions

View File

@ -1522,10 +1522,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:

View File

@ -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]