--- a/mercurial/templatefilters.py Mon Mar 23 15:14:42 2020 -0700
+++ b/mercurial/templatefilters.py Thu Mar 26 00:07:12 2020 +0900
@@ -106,12 +106,17 @@
return os.path.basename(path)
+def _tocborencodable(obj):
+ if isinstance(obj, smartset.abstractsmartset):
+ return list(obj)
+ return obj
+
+
@templatefilter(b'cbor')
def cbor(obj):
"""Any object. Serializes the object to CBOR bytes."""
- if isinstance(obj, smartset.abstractsmartset):
- # cborutil is stricter about type than json() filter
- obj = list(obj)
+ # cborutil is stricter about type than json() filter
+ obj = pycompat.rapply(_tocborencodable, obj)
return b''.join(cborutil.streamencode(obj))