commit:     d6ddb6b57d4d6b16ab5acd4200558245cd7fb143
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Thu May 13 17:56:37 2021 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Thu May 13 19:09:00 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d6ddb6b5

dev-python/ruamel-yaml-clib: support python3_10

A small change was needed for the source file _ruamel_yaml.c to compile
against this version, that said with the fix in place builds and
installs fine under all CPython versions currently in PYTHON_COMPAT,
several deprecation warnings notwithstanding. No standalone test suite
but all relevant tests from dev-python/ruamel-yaml pass.

Nb. the aforementioned source file is cython-generated so it should be
simple enough for upstream to bring up to date.

Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>

 .../files/ruamel-yaml-clib-0.2.2-python3_10.patch  | 45 ++++++++++++++++++++++
 .../ruamel-yaml-clib-0.2.2-r1.ebuild               |  6 ++-
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git 
a/dev-python/ruamel-yaml-clib/files/ruamel-yaml-clib-0.2.2-python3_10.patch 
b/dev-python/ruamel-yaml-clib/files/ruamel-yaml-clib-0.2.2-python3_10.patch
new file mode 100644
index 00000000000..6a34420de79
--- /dev/null
+++ b/dev-python/ruamel-yaml-clib/files/ruamel-yaml-clib-0.2.2-python3_10.patch
@@ -0,0 +1,45 @@
+Since Python 3.10, Py_REFCNT() can no longer be used as an l-value. See
+
+https://docs.python.org/3.10/whatsnew/3.10.html#id2
+
+for details.
+
+--- a/_ruamel_yaml.c
++++ b/_ruamel_yaml.c
+@@ -23877,9 +23877,9 @@
+   {
+     PyObject *etype, *eval, *etb;
+     PyErr_Fetch(&etype, &eval, &etb);
+-    ++Py_REFCNT(o);
++    Py_SET_REFCNT(o, Py_REFCNT(o) + 1);
+     __pyx_pw_12_ruamel_yaml_7CParser_3__dealloc__(o);
+-    --Py_REFCNT(o);
++    Py_SET_REFCNT(o, Py_REFCNT(o) - 1);
+     PyErr_Restore(etype, eval, etb);
+   }
+   Py_CLEAR(p->stream);
+@@ -24050,9 +24050,9 @@
+   {
+     PyObject *etype, *eval, *etb;
+     PyErr_Fetch(&etype, &eval, &etb);
+-    ++Py_REFCNT(o);
++    Py_SET_REFCNT(o, Py_REFCNT(o) + 1);
+     __pyx_pw_12_ruamel_yaml_8CEmitter_3__dealloc__(o);
+-    --Py_REFCNT(o);
++    Py_SET_REFCNT(o, Py_REFCNT(o) - 1);
+     PyErr_Restore(etype, eval, etb);
+   }
+   Py_CLEAR(p->stream);
+--- a/_ruamel_yaml.h
++++ b/_ruamel_yaml.h
+@@ -12,6 +12,10 @@
+ #define PyString_GET_SIZE   PyBytes_GET_SIZE
+ #define PyString_FromStringAndSize  PyBytes_FromStringAndSize
+ 
++#if PY_VERSION_HEX < 0x030900A4
++# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
++#endif
++
+ #endif
+ 
+ #ifdef _MSC_VER       /* MS Visual C++ 6.0 */

diff --git a/dev-python/ruamel-yaml-clib/ruamel-yaml-clib-0.2.2-r1.ebuild 
b/dev-python/ruamel-yaml-clib/ruamel-yaml-clib-0.2.2-r1.ebuild
index bfbba4a4408..7604a87fdc3 100644
--- a/dev-python/ruamel-yaml-clib/ruamel-yaml-clib-0.2.2-r1.ebuild
+++ b/dev-python/ruamel-yaml-clib/ruamel-yaml-clib-0.2.2-r1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( pypy3 python3_{7..9} )
+PYTHON_COMPAT=( pypy3 python3_{7..10} )
 
 inherit distutils-r1
 
@@ -18,7 +18,9 @@ LICENSE="MIT"
 SLOT="0"
 KEYWORDS="amd64 arm arm64 ~hppa ~ia64 ppc ppc64 sparc x86"
 
-RDEPEND="!<dev-python/ruamel-yaml-0.16.0"
+PATCHES=(
+        "${FILESDIR}"/${PN}-0.2.2-python3_10.patch
+)
 
 S="${WORKDIR}"/${MY_P}
 

Reply via email to