python-humanfriendly icon indicating copy to clipboard operation
python-humanfriendly copied to clipboard

parse_size doesn't recognize binary units that end with "byte," "bytes," or "s"

Open troyhoffman opened this issue 6 years ago • 2 comments

parse_size('10 MiB') returns 10485760, as expected. However, parse_size('10 MiBs') returns 10000000, as does parse_size('10 MiByte') or parse_size('10 MiBytes').

In all cases, it should be 10485760.

troyhoffman avatar Apr 13 '18 19:04 troyhoffman

This problem extends to the SI power-of-two suffixes such as "gibibyte". "gibibyte" works, "gibibytes" doesn't

gdevenyi avatar Jul 30 '19 18:07 gdevenyi

I've just released humanfriendly 7.1 which changes the situation slightly: If a trailing s was all that previously prevented correct matching then the match should now succeed. This tackles the 10 MiBs case and more generally the second comment here.

The 10 MiByte and 10 MiBytes cases are not (yet) handled as suggested because I'm divided about whether I want or should support this much diversity. I'd never seen these used before and Google reports about 10K matches, which is not exactly convincing :innocent:.

In any case I'll leave this open to enable discussion on this topic.

xolox avatar Feb 16 '20 19:02 xolox