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

Transform tree data to `bytes`.

The data in the tree test cannot be automatically converted to `bytes`
as a encoding is necessary in that case:

```python
Traceback (most recent call last):
  File "/srv/slapgrid/slappart66/git/pygolang/golang/__init__.py", line 125, in _
    return f(*argv, **kw)
  File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree/xbtreetest/treegen.py", line 281, in TreesSrv
    zblk.setblkdata(v2)
  File "/srv/slapgrid/slappart66/git/wendelin.core/bigfile/file_zodb.py", line 294, in setblkdata
    blkdata = bytes(buf)                    # FIXME does memcpy
TypeError: string argument without an encoding
```

As we know that the data is ASCII, we use the ASCII encoder to convert
it to `bytes`.
parent 5a2b639c
...@@ -260,7 +260,7 @@ def TreesSrv(zstor, r): ...@@ -260,7 +260,7 @@ def TreesSrv(zstor, r):
t, D = treetxt.split() t, D = treetxt.split()
assert D.startswith('D') assert D.startswith('D')
kv = kvDecode(t[1:], zctx.vdecode) kv = kvDecode(t[1:], zctx.vdecode)
zv = _kvDecode(D[1:], kdecode=lambda ktxt: ktxt, vdecode=lambda vtxt: vtxt) zv = _kvDecode(D[1:], kdecode=lambda ktxt: ktxt, vdecode=lambda vtxt: vtxt.encode('ascii'))
patch(ztree, diff(ztree, kv), kv) patch(ztree, diff(ztree, kv), kv)
# ~ patch(valdict, diff(valdict,zv)) but sets zblk.value on change # ~ patch(valdict, diff(valdict,zv)) but sets zblk.value on change
......
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