ensure octal format is fed an integer
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Thu, 2 Mar 2017 13:40:39 +0000 (14:40 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
Fix a “type” error that seems to be enforced by Python 3:

      File "/src/python/python-delta-tar/deltatar/tarfile.py", line 220, in itn
        s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
    TypeError: %o format: an integer is required, not float

deltatar/tarfile.py

index 9303a09..35c538d 100644 (file)
@@ -217,7 +217,7 @@ def itn(n, digits=8, format=DEFAULT_FORMAT):
     # A 0o200 byte indicates a positive number, a 0o377 byte a negative
     # number.
     if 0 <= n < 8 ** (digits - 1):
-        s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
+        s = bytes("%0*o" % (digits - 1, int(n)), "ascii") + NUL
     elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1):
         if n >= 0:
             s = bytearray([0o200])