Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgwebdir_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 | 89ce95f907bd |
children | 06320fb11699 |
comparison
equal
deleted
inserted
replaced
25659:d60678a567a9 | 25660:328739ea70c3 |
---|---|
217 req.env['REPO_NAME'] = virtualrepo | 217 req.env['REPO_NAME'] = virtualrepo |
218 try: | 218 try: |
219 # ensure caller gets private copy of ui | 219 # ensure caller gets private copy of ui |
220 repo = hg.repository(self.ui.copy(), real) | 220 repo = hg.repository(self.ui.copy(), real) |
221 return hgweb(repo).run_wsgi(req) | 221 return hgweb(repo).run_wsgi(req) |
222 except IOError, inst: | 222 except IOError as inst: |
223 msg = inst.strerror | 223 msg = inst.strerror |
224 raise ErrorResponse(HTTP_SERVER_ERROR, msg) | 224 raise ErrorResponse(HTTP_SERVER_ERROR, msg) |
225 except error.RepoError, inst: | 225 except error.RepoError as inst: |
226 raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) | 226 raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) |
227 | 227 |
228 up = virtualrepo.rfind('/') | 228 up = virtualrepo.rfind('/') |
229 if up < 0: | 229 if up < 0: |
230 break | 230 break |
238 | 238 |
239 # prefixes not found | 239 # prefixes not found |
240 req.respond(HTTP_NOT_FOUND, ctype) | 240 req.respond(HTTP_NOT_FOUND, ctype) |
241 return tmpl("notfound", repo=virtual) | 241 return tmpl("notfound", repo=virtual) |
242 | 242 |
243 except ErrorResponse, err: | 243 except ErrorResponse as err: |
244 req.respond(err, ctype) | 244 req.respond(err, ctype) |
245 return tmpl('error', error=err.message or '') | 245 return tmpl('error', error=err.message or '') |
246 finally: | 246 finally: |
247 tmpl = None | 247 tmpl = None |
248 | 248 |
334 continue | 334 continue |
335 | 335 |
336 u = self.ui.copy() | 336 u = self.ui.copy() |
337 try: | 337 try: |
338 u.readconfig(os.path.join(path, '.hg', 'hgrc')) | 338 u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
339 except Exception, e: | 339 except Exception as e: |
340 u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e)) | 340 u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e)) |
341 continue | 341 continue |
342 def get(section, name, default=None): | 342 def get(section, name, default=None): |
343 return u.config(section, name, default, untrusted=True) | 343 return u.config(section, name, default, untrusted=True) |
344 | 344 |