Repository navigation
Fix null_string_locale_max so it sorts after every PyICU key - #196
Merged
Merged
Conversation
b"x7f" is three ASCII bytes, not the byte 0x7f, and any byte string starting above 0x78 sorted after it. Use b"\xff" so the NUMAFTER sentinel really is the maximum.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #196 +/- ##
=======================================
Coverage 97.80% 97.80%
=======================================
Files 10 10
Lines 637 637
=======================================
Hits 623 623
Misses 14 14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
null_string_locale_maxinnatsort/compat/locale.py(the PyICU branch) isb"x7f" * 50, which is the three ASCII bytesx,7,frepeated, not the byte 0x7f. It is the sentinel prepended underns.NUMAFTER | ns.LOCALEso numbers sort after strings, but any sort key whose first byte is abovex(0x78) already sorts after it, sob"x7f"*50 > b"y"isFalse.Change:
b"\xff" * 50, the actual maximum byte, one line. Addedtests/test_compat_locale.py, which loads the module with a stubicuinsys.modulesand checks the sentinel againstb"\xff" * 49andb"\xfe" * 100. It fails on the current constant and passes with the change.Verified on a fresh clone at e90771d:
pytest355 passed,ruff format --check,ruff check(no new findings beyond the CPY001 every file already reports on ruff 0.16.5),mypy --strict natsort testsunchanged from main. I could not install PyICU on this host (no ICU headers), so the PyICU code path itself was exercised only through the stub; CI installslibicu-devand should cover it.Found while running an AI-assisted code review on this repository; the change and the test are mine and were verified as described.