mirror of
https://github.com/django/django.git
synced 2025-03-03 21:55:04 +00:00
Fixed #35661 -- Fixed test_too_many_digits_to_rander() test crash on PyPy.
Thanks Michał Górny for the report.
This commit is contained in:
parent
54888408a1
commit
7fb15ad5bc
@ -4,6 +4,7 @@ from django.template.defaultfilters import floatformat
|
|||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.utils.version import PYPY
|
||||||
|
|
||||||
from ..utils import setup
|
from ..utils import setup
|
||||||
|
|
||||||
@ -181,12 +182,21 @@ class FunctionTests(SimpleTestCase):
|
|||||||
"-1E10000000000000000",
|
"-1E10000000000000000",
|
||||||
"1e10000000000000000",
|
"1e10000000000000000",
|
||||||
"-1e10000000000000000",
|
"-1e10000000000000000",
|
||||||
"1" + "0" * 1_000_000,
|
|
||||||
]
|
]
|
||||||
for value in cases:
|
for value in cases:
|
||||||
with self.subTest(value=value):
|
with self.subTest(value=value):
|
||||||
self.assertEqual(floatformat(value), value)
|
self.assertEqual(floatformat(value), value)
|
||||||
|
|
||||||
|
def test_too_many_digits_to_render_very_long(self):
|
||||||
|
value = "1" + "0" * 1_000_000
|
||||||
|
if PYPY:
|
||||||
|
# PyPy casts decimal parts to int, which reaches the integer string
|
||||||
|
# conversion length limit (default 4300 digits, CVE-2020-10735).
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
floatformat(value)
|
||||||
|
else:
|
||||||
|
self.assertEqual(floatformat(value), value)
|
||||||
|
|
||||||
def test_float_dunder_method(self):
|
def test_float_dunder_method(self):
|
||||||
class FloatWrapper:
|
class FloatWrapper:
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user