mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
Correctly format integers when there are leading zeros with a grouping
character, such as "{:04,d}".format(0x100) -> "0,256".
The new padding patterns for commas-and-zeroes and underscores-and-zeroes
are smooshed together into the existing pad_zeroes to save space.
Only the two combinations of (decimal + commas) and (other bases +
underscores) are properly supported.
Also add a test for it.
Fixes issue #18082.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
10 lines
246 B
Python
10 lines
246 B
Python
try:
|
|
"%d" % 1
|
|
except TypeError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
for v in (0, 0x10, 0x1000, -0x10, -0x1000):
|
|
for sz in range(1, 12): print(("{:0%d,d}" % sz).format(v))
|
|
for sz in range(1, 12): print(("{:0%d_x}" % sz).format(v))
|