Mercurial > hg-stable
comparison mercurial/wireproto.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 | 2e07dc514073 |
children | be9c497e0bfd |
comparison
equal
deleted
inserted
replaced
36290:46c97973ee46 | 36291:af0a19d8812b |
---|---|
877 prefercompressed = info.get('prefercompressed', True) | 877 prefercompressed = info.get('prefercompressed', True) |
878 except error.Abort as exc: | 878 except error.Abort as exc: |
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)) |
890 bundler.addpart(bundle2.bundlepart('error:abort', | 890 bundler.addpart(bundle2.bundlepart('error:abort', |
891 manargs, advargs)) | 891 manargs, advargs)) |