D2342: wireproto: fix lingering str(exception) with util.forcebytestr(exception)

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sun Feb 18 20:54:25 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2342

AFFECTED FILES
  mercurial/wireproto.py

CHANGE DETAILS

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -927,7 +927,7 @@
         r = c.hex()
         success = 1
     except Exception as inst:
-        r = str(inst)
+        r = util.forcebytestr(inst)
         success = 0
     return bytesresponse('%d %s\n' % (success, r))
 
@@ -1055,12 +1055,13 @@
                 if exc.params:
                     errpart.addparam('params', '\0'.join(exc.params))
             except error.Abort as exc:
-                manargs = [('message', str(exc))]
+                manargs = [('message', util.forcebytestr(exc))]
                 advargs = []
                 if exc.hint is not None:
                     advargs.append(('hint', exc.hint))
                 bundler.addpart(bundle2.bundlepart('error:abort',
                                                    manargs, advargs))
             except error.PushRaced as exc:
-                bundler.newpart('error:pushraced', [('message', str(exc))])
+                bundler.newpart('error:pushraced',
+                                [('message', util.forcebytestr(exc))])
             return streamres_legacy(gen=bundler.getchunks())



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list