From: W. Trevor King Date: Thu, 25 Oct 2012 21:01:01 +0000 (-0400) Subject: Update exception handling to use `except X as Y` syntax. X-Git-Tag: v0.5~15 X-Git-Url: http://git.tremily.us/?p=update-copyright.git;a=commitdiff_plain;h=e873cab4167ee94548cc57c44481ec8246c4a91d Update exception handling to use `except X as Y` syntax. --- diff --git a/update_copyright/project.py b/update_copyright/project.py index 3202878..2a2c33a 100644 --- a/update_copyright/project.py +++ b/update_copyright/project.py @@ -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) diff --git a/update_copyright/utils.py b/update_copyright/utils.py index f20c301..1172351 100644 --- a/update_copyright/utils.py +++ b/update_copyright/utils.py @@ -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))) diff --git a/update_copyright/vcs/utils.py b/update_copyright/vcs/utils.py index 40406d6..bafc1da 100644 --- a/update_copyright/vcs/utils.py +++ b/update_copyright/vcs/utils.py @@ -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()