Skip to content

test#1878

Open
HrachShah wants to merge 2 commits into
httpie:masterfrom
HrachShah:fix/format-options-unicode-numeric
Open

test#1878
HrachShah wants to merge 2 commits into
httpie:masterfrom
HrachShah:fix/format-options-unicode-numeric

Conversation

@HrachShah

Copy link
Copy Markdown

test

Zo Bot 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant