summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bettler <thomas.bettler@gmail.com>2021-12-12 19:57:28 +0100
committerMatt Turner <mattst88@gentoo.org>2022-01-28 12:57:36 -0800
commit1fdb5ab85428a9310e65d2bb95145390664984e2 (patch)
tree2986361a0e1325f28f6dc49094d3dff5a78ee005 /dev-python/gst-python
parentdev-scheme/gambit: add missing ghostscript-gpl dependency (diff)
downloadgentoo-1fdb5ab85428a9310e65d2bb95145390664984e2.tar.gz
gentoo-1fdb5ab85428a9310e65d2bb95145390664984e2.tar.bz2
gentoo-1fdb5ab85428a9310e65d2bb95145390664984e2.zip
dev-python/gst-python: add python 3.10
Closes: https://bugs.gentoo.org/829009 Closes: https://github.com/gentoo/gentoo/pull/23272 Signed-off-by: Thomas Bettler <thomas.bettler@gmail.com> Signed-off-by: Matt Turner <mattst88@gentoo.org>
Diffstat (limited to 'dev-python/gst-python')
-rw-r--r--dev-python/gst-python/files/gst-python-1.18.4-avoid-treating-float-as-int.patch86
-rw-r--r--dev-python/gst-python/gst-python-1.18.4.ebuild4
2 files changed, 90 insertions, 0 deletions
diff --git a/dev-python/gst-python/files/gst-python-1.18.4-avoid-treating-float-as-int.patch b/dev-python/gst-python/files/gst-python-1.18.4-avoid-treating-float-as-int.patch
new file mode 100644
index 000000000000..d9cc6bca086b
--- /dev/null
+++ b/dev-python/gst-python/files/gst-python-1.18.4-avoid-treating-float-as-int.patch
@@ -0,0 +1,86 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Thibault Saunier <tsaunier@igalia.com>
+Date: Tue, 16 Nov 2021 23:36:10 -0300
+Subject: [PATCH] python: Avoid treating float as int
+
+Since python 3.10 implicit conversion to integers using `__int__` as
+been completely removed (was deprecated behavior in 3.9) so we need
+to cleanly handle it now.
+
+See https://gitlab.gnome.org/GNOME/pitivi/-/issues/2589
+
+Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1358>
+---
+ .../gst-python/gi/overrides/gstmodule.c | 54 ++++++++++++++++---
+ 1 file changed, 47 insertions(+), 7 deletions(-)
+
+diff --git a/subprojects/gst-python/gi/overrides/gstmodule.c b/subprojects/gst-python/gi/overrides/gstmodule.c
+index 167a1c27539a..2308eb7dcde6 100644
+--- a/gi/overrides/gstmodule.c
++++ b/gi/overrides/gstmodule.c
+@@ -104,18 +104,58 @@ gi_gst_fraction_from_value (const GValue * value)
+ static int
+ gi_gst_fraction_to_value (GValue * value, PyObject * object)
+ {
+- PyObject *numerator, *denominator;
++ glong numerator, denominator;
++ PyObject *numerator_obj, *denominator_obj, *is_integer;
+
+- numerator = PyObject_GetAttrString (object, "num");
+- if (numerator == NULL)
++ numerator_obj = PyObject_GetAttrString (object, "num");
++ if (numerator_obj == NULL)
+ goto fail;
+
+- denominator = PyObject_GetAttrString (object, "denom");
+- if (denominator == NULL)
++ is_integer = PyObject_CallMethod (numerator_obj, "is_integer", NULL);
++ if (is_integer != Py_True) {
++ PyErr_Format (PyExc_TypeError,
++ "numerator %f is not an integer.", PyFloat_AsDouble (numerator_obj));
++ Py_DECREF (is_integer);
++ goto fail;
++ }
++ Py_DECREF (is_integer);
++
++ numerator = PyFloat_AsDouble (numerator_obj);
++ if (numerator < -G_MAXINT || numerator > G_MAXINT) {
++ PyErr_Format (PyExc_ValueError,
++ "numerator %" G_GINT64_FORMAT " is out of bound. [-%d - %d]",
++ numerator, G_MAXINT, G_MAXINT);
++ goto fail;
++ }
++
++ denominator_obj = PyObject_GetAttrString (object, "denom");
++ if (denominator_obj == NULL)
+ goto fail;
+
+- gst_value_set_fraction (value,
+- PyLong_AsLong (numerator), PyLong_AsLong (denominator));
++ is_integer = PyObject_CallMethod (denominator_obj, "is_integer", NULL);
++ if (is_integer != Py_True) {
++ PyErr_Format (PyExc_TypeError,
++ "denominator %f is not an integer.",
++ PyFloat_AsDouble (denominator_obj));
++ Py_DECREF (is_integer);
++ goto fail;
++ }
++ Py_DECREF (is_integer);
++
++ denominator = PyFloat_AsDouble (denominator_obj);
++ if (denominator == 0) {
++ PyErr_SetString (PyExc_ValueError, "denominator is 0.");
++ goto fail;
++ }
++
++ if (denominator < -G_MAXINT || denominator > G_MAXINT) {
++ PyErr_Format (PyExc_ValueError,
++ "denominator %" G_GINT64_FORMAT " is out of bound. [-%d - %d]",
++ denominator, G_MAXINT, G_MAXINT);
++ goto fail;
++ }
++
++ gst_value_set_fraction (value, numerator, denominator);
+
+ return 0;
+
diff --git a/dev-python/gst-python/gst-python-1.18.4.ebuild b/dev-python/gst-python/gst-python-1.18.4.ebuild
index 911b008ead42..7b3a8d2265cd 100644
--- a/dev-python/gst-python/gst-python-1.18.4.ebuild
+++ b/dev-python/gst-python/gst-python-1.18.4.ebuild
@@ -26,6 +26,10 @@ BDEPEND="
virtual/pkgconfig
"
+PATCHES=(
+ "${FILESDIR}/${P}-avoid-treating-float-as-int.patch"
+)
+
src_prepare() {
default