Conversation
added 2 commits
June 20, 2026 23:38
parse_format_options decided whether to coerce a value to int by calling str.isnumeric(). isnumeric returns True for several character classes that int() cannot parse — Unicode vulgar fractions like ½, superscript digits like ², and other locale-specific digit systems. The mismatch was hidden: isnumeric() accepted the value, then int() raised an unhandled ValueError that propagated out of the argparse type and crashed the whole --format-options parse step. The Arabic-Indic digits (0-9 U+0660..U+0669) actually do round-trip through int() on some Python builds but produce int values whose equality with the type of the default below depended on the Python build's codec tables, so even values that "worked" could silently mismatch the default_type check. Replace the isnumeric() branch with a direct try/except int(value) fallback so anything isnumeric() let through but int() cannot parse now falls into the existing type-mismatch branch and raises a clear ArgumentTypeError naming the offending token. Added three parametrized cases to test_parse_format_options_errors covering ½, ², and ٣; the existing 13 format_options tests continue to pass.
parse_format_options already accepts negative integers (the try/except int(value) path was
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.
test