##// END OF EJS Templates
py3: get bytes-repr of network errors portably...
Augie Fackler -
r36272:af0a19d8 default
parent child Browse files
Show More
@@ -443,20 +443,20 b' class hgweb(object):'
443 443
444 444 except (error.LookupError, error.RepoLookupError) as err:
445 445 req.respond(HTTP_NOT_FOUND, ctype)
446 msg = str(err)
446 msg = pycompat.bytestr(err)
447 447 if (util.safehasattr(err, 'name') and
448 448 not isinstance(err, error.ManifestLookupError)):
449 449 msg = 'revision not found: %s' % err.name
450 450 return tmpl('error', error=msg)
451 451 except (error.RepoError, error.RevlogError) as inst:
452 452 req.respond(HTTP_SERVER_ERROR, ctype)
453 return tmpl('error', error=str(inst))
453 return tmpl('error', error=pycompat.bytestr(inst))
454 454 except ErrorResponse as inst:
455 455 req.respond(inst, ctype)
456 456 if inst.code == HTTP_NOT_MODIFIED:
457 457 # Not allowed to return a body on a 304
458 458 return ['']
459 return tmpl('error', error=str(inst))
459 return tmpl('error', error=pycompat.bytestr(inst))
460 460
461 461 def check_perm(self, rctx, req, op):
462 462 for permhook in permhooks:
@@ -121,7 +121,8 b' class wsgirequest(object):'
121 121 elif isinstance(status, int):
122 122 status = statusmessage(status)
123 123
124 self.server_write = self._start_response(status, self.headers)
124 self.server_write = self._start_response(
125 pycompat.sysstr(status), self.headers)
125 126 self._start_response = None
126 127 self.headers = []
127 128 if body is not None:
@@ -347,7 +347,7 b' def linerange(req):'
347 347 try:
348 348 return util.processlinerange(fromline, toline)
349 349 except error.ParseError as exc:
350 raise ErrorResponse(HTTP_BAD_REQUEST, str(exc))
350 raise ErrorResponse(HTTP_BAD_REQUEST, pycompat.bytestr(exc))
351 351
352 352 def formatlinerange(fromline, toline):
353 353 return '%d:%d' % (fromline + 1, toline)
@@ -879,11 +879,11 b' def getbundle(repo, proto, others):'
879 879 # cleanly forward Abort error to the client
880 880 if not exchange.bundle2requested(opts.get('bundlecaps')):
881 881 if proto.name == 'http-v1':
882 return ooberror(str(exc) + '\n')
882 return ooberror(pycompat.bytestr(exc) + '\n')
883 883 raise # cannot do better for bundle1 + ssh
884 884 # bundle2 request expect a bundle2 reply
885 885 bundler = bundle2.bundle20(repo.ui)
886 manargs = [('message', str(exc))]
886 manargs = [('message', pycompat.bytestr(exc))]
887 887 advargs = []
888 888 if exc.hint is not None:
889 889 advargs.append(('hint', exc.hint))
@@ -339,7 +339,7 b' def _handlehttperror(e, req, cmd):'
339 339
340 340 # TODO This response body assumes the failed command was
341 341 # "unbundle." That assumption is not always valid.
342 req.respond(e, HGTYPE, body='0\n%s\n' % e)
342 req.respond(e, HGTYPE, body='0\n%s\n' % pycompat.bytestr(e))
343 343
344 344 return ''
345 345
General Comments 0
You need to be logged in to leave comments. Login now