diff options
author | Joffrey F <f.joffrey@gmail.com> | 2018-02-27 00:02:21 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-02-27 00:02:21 (GMT) |
commit | 72d9b2be36f091793ae7ffc5ad751f040c6e6ad3 (patch) | |
tree | 28a8586d3eb6ef2e75fe2f7e378cdd2748c90baf /Lib/tarfile.py | |
parent | eee72d4778a5513038edd5236cdd87ccce2bc60a (diff) | |
download | cpython-72d9b2be36f091793ae7ffc5ad751f040c6e6ad3.zip cpython-72d9b2be36f091793ae7ffc5ad751f040c6e6ad3.tar.gz cpython-72d9b2be36f091793ae7ffc5ad751f040c6e6ad3.tar.bz2 |
bpo-32713: Fix tarfile.itn for large/negative float values. (GH-5434)
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index a24ee42..85119a4 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -200,8 +200,9 @@ def itn(n, digits=8, format=DEFAULT_FORMAT): # base-256 representation. This allows values up to (256**(digits-1))-1. # A 0o200 byte indicates a positive number, a 0o377 byte a negative # number. + n = int(n) if 0 <= n < 8 ** (digits - 1): - s = bytes("%0*o" % (digits - 1, int(n)), "ascii") + NUL + s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1): if n >= 0: s = bytearray([0o200]) |