commit:     4c3e67cd3367ece0c0978b3d6d6bb70e57204ce8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug  8 11:21:29 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug  8 11:30:03 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4c3e67cd

dev-python/django: Backport pypy3 test fix

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/django/django-4.2.15.ebuild             |  2 +
 dev-python/django/django-5.0.8.ebuild              |  2 +
 dev-python/django/django-5.1.ebuild                |  2 +
 .../django/files/django-5.1-more-pypy3.patch       | 51 ++++++++++++++++++++++
 4 files changed, 57 insertions(+)

diff --git a/dev-python/django/django-4.2.15.ebuild 
b/dev-python/django/django-4.2.15.ebuild
index c05445503ec7..bd2335231db9 100644
--- a/dev-python/django/django-4.2.15.ebuild
+++ b/dev-python/django/django-4.2.15.ebuild
@@ -57,6 +57,8 @@ BDEPEND="
 PATCHES=(
        "${FILESDIR}"/django-4.0-bashcomp.patch
        "${WORKDIR}"/django-4.2.8-pypy3.patch
+       # https://code.djangoproject.com/ticket/35661
+       "${FILESDIR}"/django-5.1-more-pypy3.patch
 )
 
 distutils_enable_sphinx docs --no-autodoc

diff --git a/dev-python/django/django-5.0.8.ebuild 
b/dev-python/django/django-5.0.8.ebuild
index 80dc188258c8..2357d8dbed8b 100644
--- a/dev-python/django/django-5.0.8.ebuild
+++ b/dev-python/django/django-5.0.8.ebuild
@@ -59,6 +59,8 @@ PATCHES=(
        "${WORKDIR}"/django-5.0-pypy3.patch
        # 
https://github.com/django/django/commit/3426a5c33c36266af42128ee9eca4921e68ea876
        "${FILESDIR}"/django-5.0.6-py313.patch
+       # https://code.djangoproject.com/ticket/35661
+       "${FILESDIR}"/django-5.1-more-pypy3.patch
 )
 
 distutils_enable_sphinx docs --no-autodoc

diff --git a/dev-python/django/django-5.1.ebuild 
b/dev-python/django/django-5.1.ebuild
index bd9babed87a6..1a52c318f46b 100644
--- a/dev-python/django/django-5.1.ebuild
+++ b/dev-python/django/django-5.1.ebuild
@@ -56,6 +56,8 @@ BDEPEND="
 
 PATCHES=(
        "${FILESDIR}"/django-4.0-bashcomp.patch
+       # https://code.djangoproject.com/ticket/35661
+       "${FILESDIR}"/django-5.1-more-pypy3.patch
 )
 
 distutils_enable_sphinx docs --no-autodoc

diff --git a/dev-python/django/files/django-5.1-more-pypy3.patch 
b/dev-python/django/files/django-5.1-more-pypy3.patch
new file mode 100644
index 000000000000..27663898cc55
--- /dev/null
+++ b/dev-python/django/files/django-5.1-more-pypy3.patch
@@ -0,0 +1,51 @@
+From d9aeb23edb6cc861360ffbb59a45beccafe55dcb Mon Sep 17 00:00:00 2001
+From: Mariusz Felisiak <felisiak.mari...@gmail.com>
+Date: Thu, 8 Aug 2024 08:13:29 +0200
+Subject: [PATCH] [5.1.x] Fixed #35661 -- Fixed
+ test_too_many_digits_to_rander() test crash on PyPy.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Thanks Michał Górny for the report.
+
+Backport of 7fb15ad5bcae05324ee8913e4b2c6c982e8f2de0 from main.
+---
+ .../template_tests/filter_tests/test_floatformat.py  | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/tests/template_tests/filter_tests/test_floatformat.py 
b/tests/template_tests/filter_tests/test_floatformat.py
+index 3d6c34a55232..6183f6a0691d 100644
+--- a/tests/template_tests/filter_tests/test_floatformat.py
++++ b/tests/template_tests/filter_tests/test_floatformat.py
+@@ -4,6 +4,7 @@
+ from django.test import SimpleTestCase
+ from django.utils import translation
+ from django.utils.safestring import mark_safe
++from django.utils.version import PYPY
+ 
+ from ..utils import setup
+ 
+@@ -181,12 +182,21 @@ def test_too_many_digits_to_render(self):
+             "-1E10000000000000000",
+             "1e10000000000000000",
+             "-1e10000000000000000",
+-            "1" + "0" * 1_000_000,
+         ]
+         for value in cases:
+             with self.subTest(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):
+         class FloatWrapper:
+             def __init__(self, value):

Reply via email to