xolox/python-humanfriendly

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

Opened this issue · 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.

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

xolox commented

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 😇.

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