Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/httpclient/socketutil.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 | 59df9e52b5bb |
children | 1ad9da968a2e |
comparison
equal
deleted
inserted
replaced
25659:d60678a567a9 | 25660:328739ea70c3 |
---|---|
62 af, socktype, proto, unused_canonname, sa = res | 62 af, socktype, proto, unused_canonname, sa = res |
63 try: | 63 try: |
64 sock = socket.socket(af, socktype, proto) | 64 sock = socket.socket(af, socktype, proto) |
65 logger.info("connect: (%s, %s)", host, port) | 65 logger.info("connect: (%s, %s)", host, port) |
66 sock.connect(sa) | 66 sock.connect(sa) |
67 except socket.error, msg: | 67 except socket.error as msg: |
68 logger.info('connect fail: %s %s', host, port) | 68 logger.info('connect fail: %s %s', host, port) |
69 if sock: | 69 if sock: |
70 sock.close() | 70 sock.close() |
71 sock = None | 71 sock = None |
72 continue | 72 continue |
98 "non-zero flags not allowed in calls to recv() on %s" % | 98 "non-zero flags not allowed in calls to recv() on %s" % |
99 self.__class__) | 99 self.__class__) |
100 while True: | 100 while True: |
101 try: | 101 try: |
102 return self._ssl.read(buflen) | 102 return self._ssl.read(buflen) |
103 except socket.sslerror, x: | 103 except socket.sslerror as x: |
104 if x.args[0] == socket.SSL_ERROR_WANT_READ: | 104 if x.args[0] == socket.SSL_ERROR_WANT_READ: |
105 continue | 105 continue |
106 else: | 106 else: |
107 raise x | 107 raise x |
108 | 108 |