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.
Projectmahmoud/boltons
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
| 9 | 9 | '95M' | |
| 10 | 10 | >>> bytes2human(0, 2) | |
| 11 | 11 | '0.00B' | |
| 12 | + | >>> bytes2human(1024) | |
| 13 | + | '1K' | |
| 12 | 14 | """ | |
| 13 | 15 | abs_bytes = abs(nbytes) | |
| 14 | 16 | for (size, symbol), (next_size, next_symbol) in _SIZE_RANGES: | |
| 15 | - | if abs_bytes <= next_size: | |
| 17 | + | if abs_bytes < next_size: | |
| 16 | 18 | break | |
| 17 | 19 | hnbytes = float(nbytes) / size | |
| 18 | 20 | return '{hnbytes:.{ndigits}f}{symbol}'.format(hnbytes=hnbytes, |
The check that tells the two apart
fail→pass·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
- 2026-08-06Bits
- 2026-08-06JSONLIterator
- 2026-08-06tableutils: fix Table.to_text crashes on degenerate tables and headers
- 2026-07-18backoff_iter
- 2026-07-17singularize
- 2026-07-17fix(fileutils): accept os.PathLike in AtomicSaver