mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue19995: %o, %x, %X now only accept ints
This commit is contained in:
parent
6d2ea21337
commit
df3ed242c0
6 changed files with 72 additions and 17 deletions
|
@ -196,7 +196,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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue