Mercurial > public > mercurial-scm > hg-stable
diff mercurial/encoding.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 | 1c533e23ce95 |
children | cf47bdb2183c |
line wrap: on
line diff
--- a/mercurial/encoding.py Tue Jun 23 22:38:21 2015 -0700 +++ b/mercurial/encoding.py Tue Jun 23 22:20:08 2015 -0700 @@ -138,7 +138,7 @@ except UnicodeDecodeError: u = s.decode("utf-8", "replace") # last ditch return u.encode(encoding, "replace") # can't round-trip - except LookupError, k: + except LookupError as k: raise error.Abort(k, hint="please check your locale settings") def fromlocal(s): @@ -158,10 +158,10 @@ try: return s.decode(encoding, encodingmode).encode("utf-8") - except UnicodeDecodeError, inst: + except UnicodeDecodeError as inst: sub = s[max(0, inst.start - 10):inst.start + 10] raise error.Abort("decoding near '%s': %s!" % (sub, inst)) - except LookupError, k: + except LookupError as k: raise error.Abort(k, hint="please check your locale settings") # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. @@ -330,7 +330,7 @@ return lu.encode(encoding) except UnicodeError: return s.lower() # we don't know how to fold this except in ASCII - except LookupError, k: + except LookupError as k: raise error.Abort(k, hint="please check your locale settings") def upper(s): @@ -353,7 +353,7 @@ return uu.encode(encoding) except UnicodeError: return s.upper() # we don't know how to fold this except in ASCII - except LookupError, k: + except LookupError as k: raise error.Abort(k, hint="please check your locale settings") class normcasespecs(object):