stringutil: if we get a memoryview in escapestr, coerce it to bytes
authorAugie Fackler <augie@google.com>
Fri, 10 Aug 2018 03:16:02 -0400
changeset 39063 1419ba5e3b56
parent 39062 efeeb73f54c3
child 39064 a2fa7247ca70
stringutil: if we get a memoryview in escapestr, coerce it to bytes 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. Differential Revision: https://phab.mercurial-scm.org/D4256
mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py	Fri Aug 10 03:14:52 2018 -0400
+++ b/mercurial/utils/stringutil.py	Fri Aug 10 03:16:02 2018 -0400
@@ -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]