• Kirill Smelkov's avatar
    zodbcommit: Fix stdin reading on py3 · b21fbe23
    Kirill Smelkov authored
    Zodbcommit reads input in zodbdump format from stdin and then uses
    zodbdump.DumpReader to parser that input. The parser works on binary
    data.
    
    However zodbcommit, was preparing that input data mixing bytes and
    strings, which is failing on py3:
    
        (py3.venv) kirr@deca:~/src/wendelin/z/zodbtools$ zodb commit 1.fs 00
        Ignoring index for /home/kirr/src/wendelin/z/zodbtools/1.fs
        aaa
        Traceback (most recent call last):
          File "/home/kirr/src/wendelin/venv/py3.venv/bin/zodb", line 33, in <module>
            sys.exit(load_entry_point('zodbtools', 'console_scripts', 'zodb')())
          File "/home/kirr/src/wendelin/z/zodbtools/zodbtools/zodb.py", line 129, in main
            return command_module.main(argv)
          File "/home/kirr/src/wendelin/venv/py3.venv/lib/python3.9/site-packages/decorator.py", line 232, in fun
            return caller(func, *(extras + args), **kw)
          File "/home/kirr/src/tools/go/pygolang/golang/__init__.py", line 103, in _
            return f(*argv, **kw)
          File "/home/kirr/src/wendelin/z/zodbtools/zodbtools/zodbcommit.py", line 222, in main
            zin += sys.stdin.read()
        TypeError: can't concat str to bytes
    
    -> Fix it by reading stdin in binary mode.
    
    No test currently as zodbcommit.main is not covered by tests (hopefully yet).
    b21fbe23
zodbcommit.py 8.48 KB