##// END OF EJS Templates
cborutil: fix streamencode() to handle subtypes...
Yuya Nishihara -
r42680:b6387a65 stable
parent child Browse files
Show More
@@ -214,6 +214,14 b' def streamencode(v):'
214 fn = STREAM_ENCODERS.get(v.__class__)
214 fn = STREAM_ENCODERS.get(v.__class__)
215
215
216 if not fn:
216 if not fn:
217 # handle subtypes such as encoding.localstr and util.sortdict
218 for ty in STREAM_ENCODERS:
219 if not isinstance(v, ty):
220 continue
221 fn = STREAM_ENCODERS[ty]
222 break
223
224 if not fn:
217 raise ValueError('do not know how to encode %s' % type(v))
225 raise ValueError('do not know how to encode %s' % type(v))
218
226
219 return fn(v)
227 return fn(v)
@@ -1562,6 +1562,20 b' json filter takes input as utf-8b:'
1562 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
1562 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
1563 "\udce9"
1563 "\udce9"
1564
1564
1565 cbor filter is bytes transparent, which should handle bytes subtypes
1566 as bytes:
1567
1568 $ HGENCODING=ascii hg log -T "{branch|cbor}" -r0 \
1569 > | "$PYTHON" "$TESTTMP/decodecbor.py"
1570 [
1571 '?'
1572 ]
1573 $ HGENCODING=latin-1 hg log -T "{branch|cbor}" -r0 \
1574 > | "$PYTHON" "$TESTTMP/decodecbor.py"
1575 [
1576 '\xe9'
1577 ]
1578
1565 utf8 filter:
1579 utf8 filter:
1566
1580
1567 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
1581 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
General Comments 0
You need to be logged in to leave comments. Login now