1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35172 -- Fixed intcomma for string floats.

Thanks Warwick Brown for the report.

Regression in 55519d6cf8.
This commit is contained in:
Mariusz Felisiak 2024-02-08 10:58:54 +01:00 committed by GitHub
parent aaffbabd58
commit 2f14c2cedc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 44 additions and 1 deletions

View File

@ -80,6 +80,8 @@ def intcomma(value, use_l10n=True):
if match: if match:
prefix = match[0] prefix = match[0]
prefix_with_commas = re.sub(r"\d{3}", r"\g<0>,", prefix[::-1])[::-1] prefix_with_commas = re.sub(r"\d{3}", r"\g<0>,", prefix[::-1])[::-1]
# Remove a leading comma, if needed.
prefix_with_commas = re.sub(r"^(-?),", r"\1", prefix_with_commas)
result = prefix_with_commas + result[len(prefix) :] result = prefix_with_commas + result[len(prefix) :]
return result return result

13
docs/releases/3.2.25.txt Normal file
View File

@ -0,0 +1,13 @@
===========================
Django 3.2.25 release notes
===========================
*Expected March 4, 2024*
Django 3.2.25 fixes a regression in 3.2.24.
Bugfixes
========
* Fixed a regression in Django 3.2.24 where ``intcomma`` template filter could
return a leading comma for string representation of floats (:ticket:`35172`).

13
docs/releases/4.2.11.txt Normal file
View File

@ -0,0 +1,13 @@
===========================
Django 4.2.11 release notes
===========================
*Expected March 4, 2024*
Django 4.2.11 fixes a regression in 4.2.10.
Bugfixes
========
* Fixed a regression in Django 4.2.10 where ``intcomma`` template filter could
return a leading comma for string representation of floats (:ticket:`35172`).

View File

@ -9,4 +9,5 @@ Django 5.0.3 fixes several bugs in 5.0.2.
Bugfixes Bugfixes
======== ========
* ... * Fixed a regression in Django 5.0.2 where ``intcomma`` template filter could
return a leading comma for string representation of floats (:ticket:`35172`).

View File

@ -43,6 +43,7 @@ versions of the documentation contain the release notes for any later releases.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
4.2.11
4.2.10 4.2.10
4.2.9 4.2.9
4.2.8 4.2.8
@ -97,6 +98,7 @@ versions of the documentation contain the release notes for any later releases.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
3.2.25
3.2.24 3.2.24
3.2.23 3.2.23
3.2.22 3.2.22

View File

@ -129,12 +129,18 @@ class HumanizeTests(SimpleTestCase):
-1234567.25, -1234567.25,
"100", "100",
"-100", "-100",
"100.1",
"-100.1",
"100.13",
"-100.13",
"1000", "1000",
"-1000", "-1000",
"10123", "10123",
"-10123", "-10123",
"10311", "10311",
"-10311", "-10311",
"100000.13",
"-100000.13",
"1000000", "1000000",
"-1000000", "-1000000",
"1234567.1234567", "1234567.1234567",
@ -163,12 +169,18 @@ class HumanizeTests(SimpleTestCase):
"-1,234,567.25", "-1,234,567.25",
"100", "100",
"-100", "-100",
"100.1",
"-100.1",
"100.13",
"-100.13",
"1,000", "1,000",
"-1,000", "-1,000",
"10,123", "10,123",
"-10,123", "-10,123",
"10,311", "10,311",
"-10,311", "-10,311",
"100,000.13",
"-100,000.13",
"1,000,000", "1,000,000",
"-1,000,000", "-1,000,000",
"1,234,567.1234567", "1,234,567.1234567",