changeset 36629:c98d1c6763a6

util: teach escapedata() about bytearray re.map doesn't seem to know about bytearray (at least in Python 2). Cast bytearray to a bytes to work around this inconvenience. Differential Revision: https://phab.mercurial-scm.org/D2582
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 02 Mar 2018 22:47:18 -0500
parents 70415568ea65
children 29128309c52d
files mercurial/util.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri Mar 02 22:59:12 2018 -0500
+++ b/mercurial/util.py	Fri Mar 02 22:47:18 2018 -0500
@@ -702,6 +702,9 @@
 DATA_ESCAPE_RE = remod.compile(br'[\x00-\x08\x0a-\x1f\\\x7f-\xff]')
 
 def escapedata(s):
+    if isinstance(s, bytearray):
+        s = bytes(s)
+
     return DATA_ESCAPE_RE.sub(lambda m: DATA_ESCAPE_MAP[m.group(0)], s)
 
 class fileobjectobserver(object):