One function

bytes2human in mahmoud/boltons

The author described this change as fix(strutils): bytes2human rolls over at exact powers of 1024. It counts as a record because the check below fails on the code as it stood at 8a2a93d82 and passes on 766b55473, with nothing else changed between the two runs.

Fix saved2026-06-17
Sharing licenceBSD-2-Clause · LICENSE
Change size+3 1

What the code was meant to do, written into the code itself as a docstring

Turns an integer value of *nbytes* into a human readable format. Set *ndigits* to control how many digits after the decimal point should be shown (default `0`).

The change

99 '95M'
1010 >>> bytes2human(0, 2)
1111 '0.00B'
12+ >>> bytes2human(1024)
13+ '1K'
1214 """
1315 abs_bytes = abs(nbytes)
1416 for (size, symbol), (next_size, next_symbol) in _SIZE_RANGES:
15- if abs_bytes <= next_size:
17+ if abs_bytes < next_size:
1618 break
1719 hnbytes = float(nbytes) / size
1820 return '{hnbytes:.{ndigits}f}{symbol}'.format(hnbytes=hnbytes,

The check that tells the two apart

failpass·tests/test_strutils.py::test_bytes2human

Check file tests/test_strutils.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it8a2a93d8213e1fa4da30c8167ab1a18caad17a17
Broken version dated2026-06-17
Moduleboltons.strutils
Units changedbytes2human
Fingerprint6a8e6c58421f6cc9
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in mahmoud/boltons