Patchwork D2582: util: teach escapedata() about bytearray

login
register
mail settings
Submitter phabricator
Date March 3, 2018, 3:22 p.m.
Message ID <cc694266b9136a9df4e50d2674f29ec5@localhost.localdomain>
Download mbox | patch
Permalink /patch/28783/
State Not Applicable
Headers show

Comments

phabricator - March 3, 2018, 3:22 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc98d1c6763a6: util: teach escapedata() about bytearray (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2582?vs=6426&id=6430

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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):