D4256: stringutil: if we get a memoryview in escapestr, coerce it to bytes

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Aug 10 12:07:21 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1419ba5e3b56: stringutil: if we get a memoryview in escapestr, coerce it to bytes (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4256?vs=10308&id=10316

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

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -427,6 +427,8 @@
     return encoding.trim(text, maxlength, ellipsis='...')
 
 def escapestr(s):
+    if isinstance(s, memoryview):
+        s = bytes(s)
     # call underlying function of s.encode('string_escape') directly for
     # Python 3 compatibility
     return codecs.escape_encode(s)[0]



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


More information about the Mercurial-devel mailing list