• Carlos Ramos Carreño's avatar
    Execute `zip` eagerly. · b47294e1
    Carlos Ramos Carreño authored
    The builtin `zip` in Python 3 returns an iterator, not a list.
    Thus, one cannot directly use the `len` method on the object returned
    by `zip`, or we will have errors like the following one:
    
    ```python
    Traceback (most recent call last):
      File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree/xbtreetest/treegen.py", line 617, in <module>
        main()
      File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree/xbtreetest/treegen.py", line 613, in main
        cmd(argv)
      File "/srv/slapgrid/slappart66/venvs/wendelin.core/lib/python3.9/site-packages/decorator.py", line 232, in fun
        return caller(func, *(extras + args), **kw)
      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 589, in cmd_trees
        TreesSrv(zstor, r)
      File "/srv/slapgrid/slappart66/venvs/wendelin.core/lib/python3.9/site-packages/decorator.py", line 232, in fun
        return caller(func, *(extras + args), **kw)
      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 234, in TreesSrv
        treetxtPrev = zctx.ztreetxt(ztree)
      File "/srv/slapgrid/slappart66/venvs/wendelin.core/lib/python3.9/site-packages/decorator.py", line 232, in fun
        return caller(func, *(extras + args), **kw)
      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 536, in ztreetxt
        return zctx.TopoEncode(xbtree.StructureOf(ztree))
      File "/srv/slapgrid/slappart66/venvs/wendelin.core/lib/python3.9/site-packages/decorator.py", line 232, in fun
        return caller(func, *(extras + args), **kw)
      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 542, in TopoEncode
        return xbtree.TopoEncode(tree, zctx.vencode)
      File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree.py", line 797, in TopoEncode
        for nodev in _walkBFS(tree):
      File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree.py", line 701, in _walkBFS
        for level in __walkBFS(tree):
      File "/srv/slapgrid/slappart66/git/wendelin.core/wcfs/internal/xbtree.py", line 724, in __walkBFS
        assert len(rv) == len(rn.node.children)
    TypeError: object of type 'zip' has no len()
    ```
    
    Thus, we have to create a list from the result of `zip` before calling
    `len` on it.
    b47294e1
xbtree.py 39.1 KB