dev-python/greenlet: Port to py39
authorMichał Górny <mgorny@gentoo.org>
Tue, 26 May 2020 17:00:52 +0000 (19:00 +0200)
committerMichał Górny <mgorny@gentoo.org>
Tue, 26 May 2020 18:09:44 +0000 (20:09 +0200)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
dev-python/greenlet/files/greenlet-0.4.15-py39.patch [new file with mode: 0644]
dev-python/greenlet/greenlet-0.4.15-r1.ebuild

diff --git a/dev-python/greenlet/files/greenlet-0.4.15-py39.patch b/dev-python/greenlet/files/greenlet-0.4.15-py39.patch
new file mode 100644 (file)
index 0000000..15cf75d
--- /dev/null
@@ -0,0 +1,48 @@
+From d05b62bb75e6a3e217435a1fe0f15a53e692898c Mon Sep 17 00:00:00 2001
+From: Victor Stinner <vstinner@python.org>
+Date: Wed, 18 Mar 2020 15:09:33 +0100
+Subject: [PATCH] Port to Python 3.9
+
+On Python 3.9, define _Py_DEC_REFTOTAL which has been removed by:
+https://github.com/python/cpython/commit/49932fec62c616ec88da52642339d83ae719e924
+
+Replace also PyEval_CallObjectWithKeywords() with PyObject_Call(),
+since PyEval_CallObjectWithKeywords() has been deprecated in
+Python 3.9 and PyObject_Call() has the same behavior. The only
+difference is that PyEval_CallObjectWithKeywords() can be called with
+args=NULL, but g_initialstub() ensures that args is not NULL.
+---
+ greenlet.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/greenlet.c b/greenlet.c
+index ec738b9..d37fc97 100644
+--- a/greenlet.c
++++ b/greenlet.c
+@@ -109,6 +109,16 @@ extern PyTypeObject PyGreenlet_Type;
+ #define GREENLET_USE_TRACING 1
+ #endif
++#ifndef _Py_DEC_REFTOTAL
++  /* _Py_DEC_REFTOTAL macro has been removed from Python 3.9 by:
++    https://github.com/python/cpython/commit/49932fec62c616ec88da52642339d83ae719e924 */
++#  ifdef Py_REF_DEBUG
++#    define _Py_DEC_REFTOTAL _Py_RefTotal--
++#  else
++#    define _Py_DEC_REFTOTAL
++#  endif
++#endif
++
+ /* Weak reference to the switching-to greenlet during the slp switch */
+ static PyGreenlet* volatile ts_target = NULL;
+ /* Strong reference to the switching from greenlet after the switch */
+@@ -820,8 +830,7 @@ static int GREENLET_NOINLINE(g_initialstub)(void* mark)
+                       result = NULL;
+               } else {
+                       /* call g.run(*args, **kwargs) */
+-                      result = PyEval_CallObjectWithKeywords(
+-                              run, args, kwargs);
++                      result = PyObject_Call(run, args, kwargs);
+                       Py_DECREF(args);
+                       Py_XDECREF(kwargs);
+               }
index 3773da08c6e6fffba524a43e2c24354c812d07ce..5d9f0a2d2be3a0c1ec78b592541b84822a1af15b 100644 (file)
@@ -4,7 +4,7 @@
 EAPI=7
 
 # Note: greenlet is built-in in pypy
-PYTHON_COMPAT=( python2_7 python3_{6,7,8} )
+PYTHON_COMPAT=( python2_7 python3_{6,7,8,9} )
 
 inherit distutils-r1 flag-o-matic
 
@@ -17,10 +17,9 @@ SLOT="0"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 -hppa -ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
 IUSE="doc"
 
-BDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
-
 PATCHES=(
        "${FILESDIR}"/${P}-Add-support-for-DEC-Alpha.patch
+       "${FILESDIR}"/greenlet-0.4.15-py39.patch
 )
 
 DISTUTILS_IN_SOURCE_BUILD=1