mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-32713: Fix tarfile.itn for large/negative float values. (GH-5434)
This commit is contained in:
parent
eee72d4778
commit
72d9b2be36
3 changed files with 11 additions and 1 deletions
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue