equal
deleted
inserted
replaced
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) |