Skip to content

Use the locale decimal separator in naturalsize - #523

Open
draarivpatel-ui wants to merge 1 commit into
python-humanize:mainfrom
draarivpatel-ui:fix-naturalsize-locale-decimal
Open

draarivpatel-ui wants to merge 1 commit into
python-humanize:mainfrom
draarivpatel-ui:fix-naturalsize-locale-decimal

Conversation

@draarivpatel-ui

Copy link
Copy Markdown

Fixes #460.

intcomma and intword format fractional parts with the active locale's decimal separator, but naturalsize kept the raw ASCII dot, so a French locale produced 1.5 Mo next to 1,5 everywhere else in the same output:

>>> humanize.i18n.activate("fr_FR")
>>> humanize.intcomma(1.5)
'1,5'
>>> humanize.naturalsize(1_500_000)  # before
'1.5 Mo'
>>> humanize.naturalsize(1_500_000)  # after
'1,5 Mo'

The fix swaps the decimal point for decimal_separator() when it differs, mirroring intword. When no locale is active decimal_separator() is ".", so the default output is unchanged.

The existing French naturalsize expectations in test_i18n.py encoded the inconsistent dot output (42.0 Ko); they are updated to the locale-consistent values, and a new regression test covers the fr_FR decimal comma plus the unchanged default.

intcomma and intword format the fractional part with the active
locale's decimal separator, but naturalsize kept the raw ASCII dot,
so a French locale produced '1.5 Mo' next to '1,5' everywhere else.

Replace the decimal point with decimal_separator() when it differs,
and update the French naturalsize expectations which encoded the
inconsistent output.

Fixes python-humanize#460.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:33
@agentscanapp

agentscanapp Bot commented Nov 25, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Evidence
  • Very many forks in one day: 61 repositories forked within 24 hours
  • PRs to many projects in one day: Opened PRs in 56 different repos within 24 hours
  • Very high PR volume (daily): 57 PRs within a single 24-hour window, 1 of them to repos it can push to
  • High PR volume (weekly): 57 PRs within a single 7-day window, 1 of them to repos it can push to

Last 5 PRs:

This is an automated analysis by AgentScan

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

naturalsize() ignores the locale decimal separator

2 participants