Commit eca099bc authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Iterate the example data as a string.

The example data ('abcdefghij') should be iterated as a string, and not
as `bytes`.
Iterating a `bytes` object in Python 3 returns `int`, not `bytes`,
giving the following error on decoding:

```
--- FAIL: TestΔBTail (1.26s)
panic: root['treegen/values']: key ['b']: expected str, got int64 [recovered]
        panic: file:///tmp/TestΔBTail2213686135/001/1.fs: @03f97a31f270e722: get blktab: root['treegen/values']: key ['b']: expected str, got int64 [recovered]
        panic: file:///tmp/TestΔBTail2213686135/001/1.fs: @03f97a31f270e722: get blktab: root['treegen/values']: key ['b']: expected str, got int64
```

Instead, we can iterate as a string and encode each character to `bytes`
afterwards.
parent b47294e1
......@@ -191,13 +191,14 @@ class ZCtx(object):
valdict = zctx.root.get('treegen/values', None)
if valdict is None:
valdict = zctx.root['treegen/values'] = PersistentMapping()
valv = b'abcdefghij'
valv = 'abcdefghij'
for v in valv:
v_data = v.encode('ascii')
zblk = valdict.get(v, None)
if zblk is not None and zblk.loadblkdata() == v:
if zblk is not None and zblk.loadblkdata() == v_data:
continue
zblk = ZBlk()
zblk.setblkdata(v)
zblk.setblkdata(v_data)
valdict[v] = zblk
zctx.valdict = valdict
commit('treegen/values: init %r' % valv, skipIfEmpty=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment