Mercurial > public > mercurial-scm > hg-stable
diff mercurial/keepalive.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 | bb7a911b138e |
children | a16489f9132d |
line wrap: on
line diff
--- a/mercurial/keepalive.py Tue Jun 23 22:38:21 2015 -0700 +++ b/mercurial/keepalive.py Tue Jun 23 22:20:08 2015 -0700 @@ -251,7 +251,7 @@ self._cm.add(host, h, 0) self._start_transaction(h, req) r = h.getresponse() - except (socket.error, httplib.HTTPException), err: + except (socket.error, httplib.HTTPException) as err: raise urllib2.URLError(err) # if not a persistent connection, don't try to reuse it @@ -343,7 +343,7 @@ h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector(), **skipheaders) - except (socket.error), err: + except (socket.error) as err: raise urllib2.URLError(err) for k, v in headers.items(): h.putheader(k, v) @@ -550,7 +550,7 @@ data = read(blocksize) else: self.sock.sendall(str) - except socket.error, v: + except socket.error as v: reraise = True if v[0] == errno.EPIPE: # Broken pipe if self._HTTPConnection__state == httplib._CS_REQ_SENT: @@ -605,7 +605,7 @@ status, reason = fo.status, fo.reason except AttributeError: status, reason = None, None - except IOError, e: + except IOError as e: print " EXCEPTION: %s" % e raise else: