comparison mercurial/hgweb/hgweb_mod.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 be4dc0007b8d
children 46e2c57026bc
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
188 if query: 188 if query:
189 raise ErrorResponse(HTTP_NOT_FOUND) 189 raise ErrorResponse(HTTP_NOT_FOUND)
190 if cmd in perms: 190 if cmd in perms:
191 self.check_perm(req, perms[cmd]) 191 self.check_perm(req, perms[cmd])
192 return protocol.call(self.repo, req, cmd) 192 return protocol.call(self.repo, req, cmd)
193 except ErrorResponse, inst: 193 except ErrorResponse as inst:
194 # A client that sends unbundle without 100-continue will 194 # A client that sends unbundle without 100-continue will
195 # break if we respond early. 195 # break if we respond early.
196 if (cmd == 'unbundle' and 196 if (cmd == 'unbundle' and
197 (req.env.get('HTTP_EXPECT', 197 (req.env.get('HTTP_EXPECT',
198 '').lower() != '100-continue') or 198 '').lower() != '100-continue') or
267 content = getattr(webcommands, cmd)(self, req, tmpl) 267 content = getattr(webcommands, cmd)(self, req, tmpl)
268 req.respond(HTTP_OK, ctype) 268 req.respond(HTTP_OK, ctype)
269 269
270 return content 270 return content
271 271
272 except (error.LookupError, error.RepoLookupError), err: 272 except (error.LookupError, error.RepoLookupError) as err:
273 req.respond(HTTP_NOT_FOUND, ctype) 273 req.respond(HTTP_NOT_FOUND, ctype)
274 msg = str(err) 274 msg = str(err)
275 if (util.safehasattr(err, 'name') and 275 if (util.safehasattr(err, 'name') and
276 not isinstance(err, error.ManifestLookupError)): 276 not isinstance(err, error.ManifestLookupError)):
277 msg = 'revision not found: %s' % err.name 277 msg = 'revision not found: %s' % err.name
278 return tmpl('error', error=msg) 278 return tmpl('error', error=msg)
279 except (error.RepoError, error.RevlogError), inst: 279 except (error.RepoError, error.RevlogError) as inst:
280 req.respond(HTTP_SERVER_ERROR, ctype) 280 req.respond(HTTP_SERVER_ERROR, ctype)
281 return tmpl('error', error=str(inst)) 281 return tmpl('error', error=str(inst))
282 except ErrorResponse, inst: 282 except ErrorResponse as inst:
283 req.respond(inst, ctype) 283 req.respond(inst, ctype)
284 if inst.code == HTTP_NOT_MODIFIED: 284 if inst.code == HTTP_NOT_MODIFIED:
285 # Not allowed to return a body on a 304 285 # Not allowed to return a body on a 304
286 return [''] 286 return ['']
287 return tmpl('error', error=inst.message) 287 return tmpl('error', error=inst.message)