Update exception handling to use `except X as Y` syntax.
authorW. Trevor King <wking@tremily.us>
Thu, 25 Oct 2012 21:01:01 +0000 (17:01 -0400)
committerW. Trevor King <wking@tremily.us>
Thu, 25 Oct 2012 21:01:01 +0000 (17:01 -0400)
update_copyright/project.py
update_copyright/utils.py
update_copyright/vcs/utils.py

index 3202878507de1401f4790c5f738abc9bc61bdfe3..2a2c33aad078e1e5ef55eedb75e2b0358b6d8794 100644 (file)
@@ -28,11 +28,11 @@ from . import utils as _utils
 from .vcs.git import GitBackend as _GitBackend
 try:
     from .vcs.bazaar import BazaarBackend as _BazaarBackend
-except ImportError, _bazaar_import_error:
+except ImportError as _bazaar_import_error:
     _BazaarBackend = None
 try:
     from .vcs.mercurial import MercurialBackend as _MercurialBackend
-except ImportError, _mercurial_import_error:
+except ImportError as _mercurial_import_error:
     _MercurialBackend = None
 
 
@@ -65,7 +65,7 @@ class Project (object):
             clean_section = section.replace('-', '_')
             try:
                 loader = getattr(self, '_load_{}_conf'.format(clean_section))
-            except AttributeError, e:
+            except AttributeError as e:
                 _LOG.error('invalid {} section'.format(section))
                 raise
             loader(parser=parser)
index f20c301fa60ad6eaada85e6353cf1871cd6ea6c6..117235149b469d0cb992e6c64dad59d5ee402e19 100644 (file)
@@ -128,11 +128,11 @@ def copyright_string(original_year, final_year, authors, text, info={},
     for i,paragraph in enumerate(text):
         try:
             text[i] = paragraph % info
-        except ValueError, e:
+        except ValueError as e:
             _LOG.error(
                 "{}: can't format {} with {}".format(e, paragraph, info))
             raise
-        except TypeError, e:
+        except TypeError as e:
             _LOG.error(
                 ('{}: copright text must be a list of paragraph strings, '
                  'not {}').format(e, repr(text)))
index 40406d64ad8af4e9d75a6276c61f497b4af3de9e..bafc1da62af7b5cb58d905e44d4aa5405ca9db8a 100644 (file)
@@ -51,7 +51,7 @@ def invoke(args, stdin=None, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE,
             q = _subprocess.Popen(args, stdin=_subprocess.PIPE,
                                   stdout=stdout, stderr=stderr, shell=True,
                                   cwd=cwd)
-    except OSError, e:
+    except OSError as e:
         raise ValueError([args, e])
     stdout,stderr = q.communicate(input=stdin)
     status = q.wait()