fix: correct byte conversion factors off by power of 10 in _parse_numbers()#69186
Open
algojogacor wants to merge 1 commit into
Open
fix: correct byte conversion factors off by power of 10 in _parse_numbers()#69186algojogacor wants to merge 1 commit into
algojogacor wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an independent contribution. The author has no affiliation with the project maintainers.
Summary
Fixed byte conversion factors in
_parse_numbers()where all unit suffixes were off by a factor of 10, causing incorrect size parsing. For example,"1.0K"was being parsed as10000.0instead of the correct1000.0.Root Cause
The
postPrefixesdictionary insalt/modules/disk.pyused10E3,10E6, etc. as multiplier values instead of1E3,1E6. In Python's scientific notation,10E3= 10 × 10³ = 10,000 while1E3= 1 × 10³ = 1,000. Since the prefix multipliers (K=10³, M=10⁶, G=10⁹, etc.) should represent single-base-unit multiples, the1Eprefix is correct.Fix
Changed all eight entries in the
postPrefixesdictionary from10Eto1Eprefix:Testing
Verified with the Python interpreter:
Before:
float(_parse_numbers("1.0K"))→10000.0After:
float(_parse_numbers("1.0K"))→1000.0Closes: #65490