From ea72ace12281e8620d93eb0227ea515a36ba0197 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 11 Jun 2021 09:28:16 -0700 Subject: [PATCH] pylorax: Fix mksparse ftruncate size handling Make sure that os.ftruncate() is called with an int() size. Before python 3.10 it used to handle this internally, but in 3.9 it was deprecated and in 3.10 it now raises an error: TypeError: 'float' object cannot be interpreted as an integer This makes sure that the size is truncated to an int(). The value is in bytes, so truncation does not lose anything. --- src/pylorax/imgutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py index d713e4c1..301bb523 100644 --- a/src/pylorax/imgutils.py +++ b/src/pylorax/imgutils.py @@ -141,7 +141,7 @@ def mkrootfsimg(rootdir, outfile, label, size=2, sysroot=""): def mksparse(outfile, size): '''use os.ftruncate to create a sparse file of the given size.''' with open(outfile, "w") as fobj: - os.ftruncate(fobj.fileno(), size) + os.ftruncate(fobj.fileno(), int(size)) def mkqcow2(outfile, size, options=None): '''use qemu-img to create a file of the given size.