Skip to content

gh-162375: Enforce format width and precision limits in _pydecimal - #162380

Open
asisec wants to merge 2 commits into
python:mainfrom
asisec:fix-pydecimal-format-width-limit
Open

asisec wants to merge 2 commits into
python:mainfrom
asisec:fix-pydecimal-format-width-limit

Conversation

@asisec

@asisec asisec commented Nov 21, 2026 •

Copy link
Copy Markdown

Enforce MAX_PREC limits on minimumwidth and precision in _pydecimal._parse_format_specifier() to match _decimal and prevent unbounded CPU and memory usage on excessive specifiers.

Also optimize _pydecimal._insert_thousands_sep() when thousands_sep is empty by padding directly in one step rather than looping in groups of 3.

Enforce MAX_PREC limits on minimumwidth and precision in _pydecimal._parse_format_specifier() to match _decimal and prevent unbounded CPU and memory usage on excessive specifiers.

Also optimize _pydecimal._insert_thousands_sep() when thousands_sep is empty by padding directly in one step rather than looping in groups of 3.
@python-cla-bot

python-cla-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant