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

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Aug 10 15:08:19 UTC 2018


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

REVISION SUMMARY
  Otherwise we get an exception. Sadly, this manifesting deep inside the
  wireproto code, inside a future. For some reason the exception was
  /causing a hang/ rather than actually propagating out, which seems
  like it might merit some investigation in the future.

REPOSITORY
  rHG Mercurial

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