Use except x as y instead of except x, y

According to https://docs.python.org/3/howto/pyporting.html the
syntax changed in Python 3.x. The new syntax is usable with
Python >= 2.6 and should be preferred to be compatible with Python3.

Enabled hacking check H231.

Change-Id: I2c41dc3ec83e79181e8fd50e76771a74c393269c
This commit is contained in:
Christian Berendt 2014-05-30 00:06:44 +02:00 committed by Samuel Merritt
parent 0af4f035e2
commit f6ff06b678
3 changed files with 3 additions and 3 deletions

View File

@ -543,7 +543,7 @@ class TestReaper(unittest.TestCase):
with patch('swift.account.reaper.random.random', fake_random):
try:
r.run_forever()
except Exception, err:
except Exception as err:
pass
self.assertEqual(self.val, 1)
self.assertEqual(str(err), 'exit')

View File

@ -79,7 +79,7 @@ class TestCliInfoBase(unittest.TestCase):
def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
try:
func(*args, **kwargs)
except Exception, e:
except Exception as e:
self.assertTrue(msg in str(e),
"Expected %r in %r" % (msg, str(e)))
self.assertTrue(isinstance(e, exc),

View File

@ -59,6 +59,6 @@ commands = {posargs}
# H501 -> don't use locals() for str formatting
# H903 -> \n not \r\n
ignore = H
select = F,E,W,H102,H103,H501,H903
select = F,E,W,H102,H103,H501,H903,H231
exclude = .venv,.tox,dist,doc,*egg
show-source = True