[Tarantool-patches] [PATCH v1 2/4] test: fix xlog-py/big_lsn.test.py

Alexander Turenko alexander.turenko at tarantool.org
Thu Jan 14 15:38:43 MSK 2021


> @@ -17,7 +18,7 @@ new_lsn = 123456789123
>  wal_dir = os.path.join(server.vardir, server.name)
>  old_wal = os.path.join(wal_dir, "%020d.xlog" % old_lsn)
>  new_wal = os.path.join(wal_dir, "%020d.xlog" % new_lsn)
> -with open(old_wal, "r+") as f:
> +with codecs.open(old_wal, "r+", encoding = "ISO-8859-1") as f:

Nit: PEP-8 requires func(foo='bar') -- without surrounding whitespaces.

I would read the binary file using 'rb+' (to bytes) and convert strings,
which are known to be correct utf-8/ascii to Python strings (unicode)
manually, but your solution should work too (and requires less code).

I was afraid that f.read() will see some bytes that're undefined in the
ISO-8859-1 encoding and it'll lead to an exception like it does for
UTF-8. But no, it just returns u'\x00' or kinda.

Okay so.


More information about the Tarantool-patches mailing list