Patchwork [06,of,10] py3: byte-stringify ValueError of unescapestr() to reraise as ParseError

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 12:26 a.m.
Message ID <1d65b2d4de6f87f079ae.1519950385@mimosa>
Download mbox | patch
Permalink /patch/28630/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 12:26 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519941820 18000
#      Thu Mar 01 17:03:40 2018 -0500
# Node ID 1d65b2d4de6f87f079ae9d29843ee5e8fb675a23
# Parent  3a9920b08348866d5d9f2f85b9d332544686b843
py3: byte-stringify ValueError of unescapestr() to reraise as ParseError

Patch

diff --git a/mercurial/parser.py b/mercurial/parser.py
--- a/mercurial/parser.py
+++ b/mercurial/parser.py
@@ -22,6 +22,7 @@  from .i18n import _
 from . import (
     encoding,
     error,
+    pycompat,
     util,
 )
 
@@ -192,7 +193,7 @@  def unescapestr(s):
         return util.unescapestr(s)
     except ValueError as e:
         # mangle Python's exception into our format
-        raise error.ParseError(str(e).lower())
+        raise error.ParseError(pycompat.bytestr(e).lower())
 
 def _brepr(obj):
     if isinstance(obj, bytes):