One function

convert_size_bytes_to_string in fabiocaccamo/python-fsutil

The author described this change as Fix `IndexError` in `convert_size_bytes_to_string` for sizes >= 1024 YB. (#186). It counts as a record because the check below fails on the code as it stood at c98dbf6bc and passes on 4abb5aaeb, with nothing else changed between the two runs.

Fix saved2026-07-07
Sharing licenceMIT · LICENSE.txt
Change size+1 1

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

Convert the given size bytes to string using the right unit suffix.

The change

66 units = SIZE_UNITS
77 factor = 0
88 factor_limit = len(units) - 1
9- while (size_num >= 1024) and (factor <= factor_limit):
9+ while (size_num >= 1024) and (factor < factor_limit):
1010 size_num /= 1024
1111 factor += 1
1212 size_units = units[factor]

The check that tells the two apart

failpass·tests/test_converters.py::test_convert_size_bytes_to_string[1237940039285380274899124224-1024.00

Check file tests/test_converters.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 itc98dbf6bc7c0c7686631c7d3d34b0436ed6c62f0
Broken version dated2026-05-11
Modulefsutil.converters
Units changedconvert_size_bytes_to_string
Fingerprint506fafc76c61ab6f
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 fabiocaccamo/python-fsutil