mirror of
https://github.com/django/django.git
synced 2025-12-23 09:19:27 +00:00
Fixed #36715 -- Handled non-finite Decimals in intcomma filter.
This commit is contained in:
parent
e78420c2b8
commit
fffa64abc3
2 changed files with 9 additions and 0 deletions
|
|
@ -48,6 +48,9 @@ def format(
|
|||
if abs(number) < cutoff:
|
||||
number = Decimal("0")
|
||||
|
||||
if not number.is_finite():
|
||||
return str(number)
|
||||
|
||||
# Format values with more than 200 digits (an arbitrary cutoff) using
|
||||
# scientific notation to avoid high memory usage in {:f}'.format().
|
||||
_, digits, exponent = number.as_tuple()
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ class HumanizeTests(SimpleTestCase):
|
|||
"-1234567.1234567",
|
||||
Decimal("1234567.1234567"),
|
||||
Decimal("-1234567.1234567"),
|
||||
Decimal("Infinity"),
|
||||
Decimal("-Infinity"),
|
||||
Decimal("NaN"),
|
||||
None,
|
||||
"1234567",
|
||||
"-1234567",
|
||||
|
|
@ -193,6 +196,9 @@ class HumanizeTests(SimpleTestCase):
|
|||
"-1,234,567.1234567",
|
||||
"1,234,567.1234567",
|
||||
"-1,234,567.1234567",
|
||||
"Infinity",
|
||||
"-Infinity",
|
||||
"NaN",
|
||||
None,
|
||||
"1,234,567",
|
||||
"-1,234,567",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue