Mercurial > hg
diff mercurial/wireproto.py @ 25660:328739ea70c3
global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".
This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.
This patch was produced by running `2to3 -f except -w -n .`.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 23 Jun 2015 22:20:08 -0700 |
parents | d8e7b0781ad7 |
children | 5cda0ce05c42 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Tue Jun 23 22:38:21 2015 -0700 +++ b/mercurial/wireproto.py Tue Jun 23 22:20:08 2015 -0700 @@ -705,7 +705,7 @@ c = repo[k] r = c.hex() success = 1 - except Exception, inst: + except Exception as inst: r = str(inst) success = 0 return "%s %s\n" % (success, r) @@ -800,7 +800,7 @@ fp.close() os.unlink(tempname) - except (error.BundleValueError, util.Abort, error.PushRaced), exc: + except (error.BundleValueError, util.Abort, error.PushRaced) as exc: # handle non-bundle2 case first if not getattr(exc, 'duringunbundle2', False): try: @@ -821,7 +821,7 @@ try: try: raise - except error.PushkeyFailed, exc: + except error.PushkeyFailed as exc: # check client caps remotecaps = getattr(exc, '_replycaps', None) if (remotecaps is not None @@ -840,19 +840,19 @@ part.addparam('old', exc.old, mandatory=False) if exc.ret is not None: part.addparam('ret', exc.ret, mandatory=False) - except error.BundleValueError, exc: + except error.BundleValueError as exc: errpart = bundler.newpart('error:unsupportedcontent') if exc.parttype is not None: errpart.addparam('parttype', exc.parttype) if exc.params: errpart.addparam('params', '\0'.join(exc.params)) - except util.Abort, exc: + except util.Abort as exc: manargs = [('message', str(exc))] advargs = [] if exc.hint is not None: advargs.append(('hint', exc.hint)) bundler.addpart(bundle2.bundlepart('error:abort', manargs, advargs)) - except error.PushRaced, exc: + except error.PushRaced as exc: bundler.newpart('error:pushraced', [('message', str(exc))]) return streamres(bundler.getchunks())