comparison mercurial/hgweb/server.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 dc4d2cd3aa3e
children 04af43009c8b
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
69 ''.join([' %s:%s' % h for h in sorted(xheaders)])) 69 ''.join([' %s:%s' % h for h in sorted(xheaders)]))
70 70
71 def do_write(self): 71 def do_write(self):
72 try: 72 try:
73 self.do_hgweb() 73 self.do_hgweb()
74 except socket.error, inst: 74 except socket.error as inst:
75 if inst[0] != errno.EPIPE: 75 if inst[0] != errno.EPIPE:
76 raise 76 raise
77 77
78 def do_POST(self): 78 def do_POST(self):
79 try: 79 try:
224 224
225 def do_write(self): 225 def do_write(self):
226 import OpenSSL 226 import OpenSSL
227 try: 227 try:
228 _httprequesthandler.do_write(self) 228 _httprequesthandler.do_write(self)
229 except OpenSSL.SSL.SysCallError, inst: 229 except OpenSSL.SSL.SysCallError as inst:
230 if inst.args[0] != errno.EPIPE: 230 if inst.args[0] != errno.EPIPE:
231 raise 231 raise
232 232
233 def handle_one_request(self): 233 def handle_one_request(self):
234 import OpenSSL 234 import OpenSSL
342 342
343 address = ui.config('web', 'address', '') 343 address = ui.config('web', 'address', '')
344 port = util.getport(ui.config('web', 'port', 8000)) 344 port = util.getport(ui.config('web', 'port', 8000))
345 try: 345 try:
346 return cls(ui, app, (address, port), handler) 346 return cls(ui, app, (address, port), handler)
347 except socket.error, inst: 347 except socket.error as inst:
348 raise util.Abort(_("cannot start server at '%s:%d': %s") 348 raise util.Abort(_("cannot start server at '%s:%d': %s")
349 % (address, port, inst.args[1])) 349 % (address, port, inst.args[1]))