Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/stringutil.py @ 39063:1419ba5e3b56
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
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 10 Aug 2018 03:16:02 -0400 |
parents | 38409be2f521 |
children | ce145f8eface |
comparison
equal
deleted
inserted
replaced
39062:efeeb73f54c3 | 39063:1419ba5e3b56 |
---|---|
425 def ellipsis(text, maxlength=400): | 425 def ellipsis(text, maxlength=400): |
426 """Trim string to at most maxlength (default: 400) columns in display.""" | 426 """Trim string to at most maxlength (default: 400) columns in display.""" |
427 return encoding.trim(text, maxlength, ellipsis='...') | 427 return encoding.trim(text, maxlength, ellipsis='...') |
428 | 428 |
429 def escapestr(s): | 429 def escapestr(s): |
430 if isinstance(s, memoryview): | |
431 s = bytes(s) | |
430 # call underlying function of s.encode('string_escape') directly for | 432 # call underlying function of s.encode('string_escape') directly for |
431 # Python 3 compatibility | 433 # Python 3 compatibility |
432 return codecs.escape_encode(s)[0] | 434 return codecs.escape_encode(s)[0] |
433 | 435 |
434 def unescapestr(s): | 436 def unescapestr(s): |