diff mercurial/httppeer.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 00ecc894138d
children 7bbdb78d2842
line wrap: on
line diff
--- a/mercurial/httppeer.py	Tue Jun 23 22:38:21 2015 -0700
+++ b/mercurial/httppeer.py	Tue Jun 23 22:20:08 2015 -0700
@@ -119,11 +119,11 @@
             req.add_unredirected_header('Content-Length', '%d' % size)
         try:
             resp = self.urlopener.open(req)
-        except urllib2.HTTPError, inst:
+        except urllib2.HTTPError as inst:
             if inst.code == 401:
                 raise util.Abort(_('authorization failed'))
             raise
-        except httplib.HTTPException, inst:
+        except httplib.HTTPException as inst:
             self.ui.debug('http error while sending %s command\n' % cmd)
             self.ui.traceback()
             raise IOError(None, inst)
@@ -205,7 +205,7 @@
             if len(vals) < 2:
                 raise error.ResponseError(_("unexpected response:"), r)
             return vals
-        except socket.error, err:
+        except socket.error as err:
             if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
                 raise util.Abort(_('push failed: %s') % err.args[1])
             raise util.Abort(err.args[1])
@@ -267,7 +267,7 @@
             # No luck, try older compatibility check.
             inst.between([(nullid, nullid)])
         return inst
-    except error.RepoError, httpexception:
+    except error.RepoError as httpexception:
         try:
             r = statichttprepo.instance(ui, "static-" + path, create)
             ui.note('(falling back to static-http)\n')