From 678c4b3c05a1fede67ffffbfefcd9dd4981883f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Wed, 21 Sep 2022 10:52:24 +0700 Subject: [PATCH] zbar: fix build for python 3.11 --- srcpkgs/zbar/patches/PyEval_InitThreads.patch | 41 ++++++++++++++ srcpkgs/zbar/patches/python-3.11.patch | 53 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 srcpkgs/zbar/patches/PyEval_InitThreads.patch create mode 100644 srcpkgs/zbar/patches/python-3.11.patch diff --git a/srcpkgs/zbar/patches/PyEval_InitThreads.patch b/srcpkgs/zbar/patches/PyEval_InitThreads.patch new file mode 100644 index 00000000000..603f748e887 --- /dev/null +++ b/srcpkgs/zbar/patches/PyEval_InitThreads.patch @@ -0,0 +1,41 @@ +From 923da762e890f8a4516e8d5ef1314ae84703ab5d Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +Date: Wed, 23 Dec 2020 11:56:08 +0100 +Subject: [PATCH] python: get rid of a Python 3.9 warning + +As mentioned on: + https://cpython-ericholscher.readthedocs.io/en/sphinx-hoverxref/whatsnew/3.9.html + +The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are now +deprecated and will be removed in Python 3.11. Calling PyEval_InitThreads() +now does nothing. The GIL is initialized by Py_Initialize() since Python 3.7. + +So, let's not call it on Python 3.9, in order to avoid a +warning noise. + +Signed-off-by: Mauro Carvalho Chehab +--- + python/processor.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/python/processor.c b/python/processor.c +index 44e3a9d..52597df 100644 +--- a/python/processor.c ++++ b/python/processor.c +@@ -43,11 +43,13 @@ processor_new (PyTypeObject *type, + return(NULL); + + #ifdef WITH_THREAD ++# if (PY_MAJOR_VERSION < 3) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) + /* the processor creates a thread that calls back into python, + * so we must ensure that threads are initialized before attempting + * to manipulate the GIL (bug #3349199) + */ + PyEval_InitThreads(); ++# endif + #else + if(threaded > 0 && + PyErr_WarnEx(NULL, "threading requested but not available", 1)) +-- +2.38.0.rc0 + diff --git a/srcpkgs/zbar/patches/python-3.11.patch b/srcpkgs/zbar/patches/python-3.11.patch new file mode 100644 index 00000000000..983dd6d6647 --- /dev/null +++ b/srcpkgs/zbar/patches/python-3.11.patch @@ -0,0 +1,53 @@ +From 3d9cb93e3e23624baf2b36acd0d1cd2e2ca03b2b Mon Sep 17 00:00:00 2001 +From: Đoàn Trần Công Danh +Date: Wed, 21 Sep 2022 10:32:11 +0700 +Subject: [PATCH] python: enum: fix build for Python 3.11 + +Python 3.9 introduced Py_SET_SIZE function to set size instead of +relying on Py_SIZE() as a macro [3.9]. + +Python 3.10 started to encourage to use Py_SET_SIZE instead of +assigning into return value of Py_SIZE [3.10]. + +Python 3.11 flips the switch, turn Py_SIZE into a function [3.11], +thus Py_SIZE(obj) will be a rvalue. We need to use Py_SET_SIZE +to set size now. + +[3.9]: https://docs.python.org/3.9/c-api/structures.html#c.Py_SET_SIZE +[3.10]: https://docs.python.org/3.10/c-api/structures.html#c.Py_SIZE +[3.11]: https://docs.python.org/3.11/c-api/structures.html#c.Py_SIZE +--- + python/enum.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/python/enum.c b/python/enum.c +index a113553..a034a35 100644 +--- a/python/enum.c ++++ b/python/enum.c +@@ -52,7 +52,11 @@ enumitem_new (PyTypeObject *type, + + /* we assume the "fast path" for a single-digit ints (see longobject.c) */ + /* this also holds if we get a small_int preallocated long */ ++#if PY_MINOR_VERSION >= 9 ++ Py_SET_SIZE(&self->val, Py_SIZE(longval)); ++#else + Py_SIZE(&self->val) = Py_SIZE(longval); ++#endif + self->val.ob_digit[0] = longval->ob_digit[0]; + Py_DECREF(longval); + #else +@@ -138,7 +142,11 @@ zbarEnumItem_New (PyObject *byname, + + /* we assume the "fast path" for a single-digit ints (see longobject.c) */ + /* this also holds if we get a small_int preallocated long */ ++#if PY_MINOR_VERSION >= 9 ++ Py_SET_SIZE(&self->val, Py_SIZE(longval)); ++#else + Py_SIZE(&self->val) = Py_SIZE(longval); ++#endif + self->val.ob_digit[0] = longval->ob_digit[0]; + Py_DECREF(longval); + +-- +2.38.0.rc0 +