Mercurial > public > mercurial-scm > hg-stable
diff tests/test-template-functions.t @ 42176:b6387a65851d stable
cborutil: fix streamencode() to handle subtypes
Otherwise the template filter 'cbor' could crash because of bytes subclass:
ValueError: do not know how to encode
<class 'mercurial.encoding.safelocalstr'>
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 16 Jun 2019 12:31:07 +0900 |
parents | a66965406528 |
children | 34a46d48d24e |
line wrap: on
line diff
--- a/tests/test-template-functions.t Fri May 31 22:37:14 2019 -0700 +++ b/tests/test-template-functions.t Sun Jun 16 12:31:07 2019 +0900 @@ -1562,6 +1562,20 @@ $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1 "\udce9" +cbor filter is bytes transparent, which should handle bytes subtypes +as bytes: + + $ HGENCODING=ascii hg log -T "{branch|cbor}" -r0 \ + > | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + '?' + ] + $ HGENCODING=latin-1 hg log -T "{branch|cbor}" -r0 \ + > | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + '\xe9' + ] + utf8 filter: $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0