commit:     72ba0fa7364ce1802bca62d5429d23758c3dd19e
Author:     Arthur Zamarin <arthurzam <AT> gmail <DOT> com>
AuthorDate: Fri Jul 30 08:43:14 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug  2 08:40:47 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=72ba0fa7

dev-python/regex: enable support for pypy3

uses custom patches that try to fix the two last test failures here:
https://bitbucket.org/mrabarnett/mrab-regex/issues/404/

Signed-off-by: Arthur Zamarin <arthurzam <AT> gmail.com>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 ...regex-2021.4.4-pypy3-fix-test_empty_array.patch | 35 ++++++++++++++++++++++
 ...regex-2021.4.4-pypy3-fix-test_issue_18468.patch | 31 +++++++++++++++++++
 dev-python/regex/regex-2021.4.4.ebuild             |  7 ++++-
 dev-python/regex/regex-2021.7.1.ebuild             |  7 ++++-
 dev-python/regex/regex-2021.7.6.ebuild             |  7 ++++-
 5 files changed, 84 insertions(+), 3 deletions(-)

diff --git 
a/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_empty_array.patch 
b/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_empty_array.patch
new file mode 100644
index 00000000000..706b41b7468
--- /dev/null
+++ b/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_empty_array.patch
@@ -0,0 +1,35 @@
+From: Arthur Zamarin <[email protected]>
+Date: Fri, 30 Jul 2021 11:13:41 +0300
+[PATCH] PyPy3: fix test_empty_array
+
+As an optimization, PyPy sets empty array.array to use a NULL buffer
+pointer, while CPython uses empty buffer (but not NULL).
+Add a very specially crafted fix for PyPy3
+
+Signed-off-by: Arthur Zamarin <[email protected]>
+---
+ regex_3/_regex.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/regex_3/_regex.c
++++ b/regex_3/_regex.c
+@@ -18062,9 +18062,19 @@ Py_LOCAL_INLINE(BOOL) get_string(PyObject* string, 
RE_StringInfo* str_info) {
+     }
+ 
+     if (!str_info->view.buf) {
++#if defined(PYPY_VERSION)
++        /* In PyPy3, when the array.array is empty, it's buffer is NULL */
++        str_info->characters = NULL;
++        str_info->length = 0;
++        str_info->charsize = 1;
++        str_info->is_unicode = FALSE;
++        str_info->should_release = FALSE;
++        return TRUE;
++#else
+         PyBuffer_Release(&str_info->view);
+         PyErr_SetString(PyExc_ValueError, "buffer is NULL");
+         return FALSE;
++#endif
+     }
+ 
+     str_info->should_release = TRUE;

diff --git 
a/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_issue_18468.patch 
b/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_issue_18468.patch
new file mode 100644
index 00000000000..ae595802178
--- /dev/null
+++ b/dev-python/regex/files/regex-2021.4.4-pypy3-fix-test_issue_18468.patch
@@ -0,0 +1,31 @@
+From: Arthur Zamarin <[email protected]>
+Date: Fri, 30 Jul 2021 11:38:26 +0300
+[PATCH] PyPy3: fix test_issue_18468
+
+When using the small subclass classes to test correctness of split
+results, there are difference between CPython and PyPy3:
+ - CPython returns always the base class (for example str instead
+   of StrSubclass)
+ - PyPy3 returns the same class, so we get an StrSubclass
+
+Based on the test, it looks like the behaviour of PyPy3 is correct,
+but the test works based on CPython.
+
+The fix was to relax the equals type to check that it is a subclass.
+
+Signed-off-by: Arthur Zamarin <[email protected]>
+---
+ regex_3/test_regex.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/regex_3/test_regex.py
++++ b/regex_3/test_regex.py
+@@ -52,7 +52,7 @@ class RegexTests(unittest.TestCase):
+                 for x, y in zip(actual, expect):
+                     recurse(x, y)
+             else:
+-                self.assertIs(type(actual), type(expect), msg)
++                self.assertIsInstance(actual, type(expect), msg)
+ 
+         recurse(actual, expect)
+ 

diff --git a/dev-python/regex/regex-2021.4.4.ebuild 
b/dev-python/regex/regex-2021.4.4.ebuild
index 80f758e55ed..738d258d1ab 100644
--- a/dev-python/regex/regex-2021.4.4.ebuild
+++ b/dev-python/regex/regex-2021.4.4.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( python3_{7..10} )
+PYTHON_COMPAT=( python3_{8..10} pypy3 )
 
 inherit distutils-r1 flag-o-matic
 
@@ -16,6 +16,11 @@ SLOT="0"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc 
x86 ~x64-macos"
 IUSE="doc"
 
+PATCHES=(
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_empty_array.patch"
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_issue_18468.patch"
+)
+
 distutils_enable_tests unittest
 
 python_test() {

diff --git a/dev-python/regex/regex-2021.7.1.ebuild 
b/dev-python/regex/regex-2021.7.1.ebuild
index 271faa2b4fe..c0a5a26d5c4 100644
--- a/dev-python/regex/regex-2021.7.1.ebuild
+++ b/dev-python/regex/regex-2021.7.1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{8..10} )
+PYTHON_COMPAT=( python3_{8..10} pypy3 )
 inherit distutils-r1 flag-o-matic
 
 DESCRIPTION="Alternative regular expression module to replace re"
@@ -15,6 +15,11 @@ SLOT="0"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 
~sparc ~x86 ~x64-macos"
 IUSE="doc"
 
+PATCHES=(
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_empty_array.patch"
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_issue_18468.patch"
+)
+
 distutils_enable_tests unittest
 
 python_test() {

diff --git a/dev-python/regex/regex-2021.7.6.ebuild 
b/dev-python/regex/regex-2021.7.6.ebuild
index 271faa2b4fe..c0a5a26d5c4 100644
--- a/dev-python/regex/regex-2021.7.6.ebuild
+++ b/dev-python/regex/regex-2021.7.6.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{8..10} )
+PYTHON_COMPAT=( python3_{8..10} pypy3 )
 inherit distutils-r1 flag-o-matic
 
 DESCRIPTION="Alternative regular expression module to replace re"
@@ -15,6 +15,11 @@ SLOT="0"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 
~sparc ~x86 ~x64-macos"
 IUSE="doc"
 
+PATCHES=(
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_empty_array.patch"
+       "${FILESDIR}/${PN}-2021.4.4-pypy3-fix-test_issue_18468.patch"
+)
+
 distutils_enable_tests unittest
 
 python_test() {

Reply via email to