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