Commit bbb0038e authored by Marco Mariani's avatar Marco Mariani

except .. as .. syntax

parent 22384aae
...@@ -95,7 +95,7 @@ class Recipe(object): ...@@ -95,7 +95,7 @@ class Recipe(object):
elif retcode > 0: elif retcode > 0:
log.error('Command failed with exit code %s: %s' % (retcode, cmd)) log.error('Command failed with exit code %s: %s' % (retcode, cmd))
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
except OSError, e: except OSError as e:
log.error('Command failed: %s: %s' % (e, cmd)) log.error('Command failed: %s: %s' % (e, cmd))
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
...@@ -148,7 +148,7 @@ class Recipe(object): ...@@ -148,7 +148,7 @@ class Recipe(object):
current_dir = os.getcwd() current_dir = os.getcwd()
try: try:
os.mkdir(self.options['location']) os.mkdir(self.options['location'])
except OSError, e: except OSError as e:
if e.errno == errno.EEXIST: if e.errno == errno.EEXIST:
pass pass
os.chdir(compile_dir) os.chdir(compile_dir)
......
...@@ -48,7 +48,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -48,7 +48,7 @@ class NonInformativeTests(unittest.TestCase):
parts_directory_path = os.path.join(self.dir, 'test_parts') parts_directory_path = os.path.join(self.dir, 'test_parts')
try: try:
os.mkdir(parts_directory_path) os.mkdir(parts_directory_path)
except OSError, e: except OSError as e:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise raise
bo = { bo = {
...@@ -167,7 +167,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -167,7 +167,7 @@ class NonInformativeTests(unittest.TestCase):
try: try:
recipe.call_script('%s:my_hook' % filename) recipe.call_script('%s:my_hook' % filename)
self.fail("The hook script was not called.") self.fail("The hook script was not called.")
except ValueError, e: except ValueError as e:
self.assertEquals(str(e), 'I got called') self.assertEquals(str(e), 'I got called')
def test_call_script__augmented_environment_as_third_parameter(self): def test_call_script__augmented_environment_as_third_parameter(self):
...@@ -189,7 +189,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -189,7 +189,7 @@ class NonInformativeTests(unittest.TestCase):
try: try:
recipe.call_script('%s:my_hook' % filename) recipe.call_script('%s:my_hook' % filename)
self.fail("The hook script was not called.") self.fail("The hook script was not called.")
except ValueError, e: except ValueError as e:
self.assertEquals(str(e), 'sentinel bar') self.assertEquals(str(e), 'sentinel bar')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment