mercurial/utils/cborutil.py
branchstable
changeset 42480 b6387a65851d
parent 40124 b638219a23c3
child 43076 2372284d9457
equal deleted inserted replaced
42421:d532292eff22 42480:b6387a65851d
   210     that each emitted chunk fully decodes to a value or sub-value.
   210     that each emitted chunk fully decodes to a value or sub-value.
   211 
   211 
   212     Encoding is deterministic - unordered collections are sorted.
   212     Encoding is deterministic - unordered collections are sorted.
   213     """
   213     """
   214     fn = STREAM_ENCODERS.get(v.__class__)
   214     fn = STREAM_ENCODERS.get(v.__class__)
       
   215 
       
   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
   215 
   223 
   216     if not fn:
   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)