Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/hgweb_mod.py @ 36291:af0a19d8812b
py3: get bytes-repr of network errors portably
This resolves a lot of weird issues in Python 3 around error strings.
Differential Revision: https://phab.mercurial-scm.org/D2295
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 17 Feb 2018 01:11:48 -0500 |
parents | 98a00aa0288d |
children | a87093e2805d |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Sat Feb 17 01:09:56 2018 -0500 +++ b/mercurial/hgweb/hgweb_mod.py Sat Feb 17 01:11:48 2018 -0500 @@ -443,20 +443,20 @@ except (error.LookupError, error.RepoLookupError) as err: req.respond(HTTP_NOT_FOUND, ctype) - msg = str(err) + msg = pycompat.bytestr(err) if (util.safehasattr(err, 'name') and not isinstance(err, error.ManifestLookupError)): msg = 'revision not found: %s' % err.name return tmpl('error', error=msg) except (error.RepoError, error.RevlogError) as inst: req.respond(HTTP_SERVER_ERROR, ctype) - return tmpl('error', error=str(inst)) + return tmpl('error', error=pycompat.bytestr(inst)) except ErrorResponse as inst: req.respond(inst, ctype) if inst.code == HTTP_NOT_MODIFIED: # Not allowed to return a body on a 304 return [''] - return tmpl('error', error=str(inst)) + return tmpl('error', error=pycompat.bytestr(inst)) def check_perm(self, rctx, req, op): for permhook in permhooks: