diff options
| author | Nick Cao <nickcao@nichi.co> | 2023-02-07 17:08:57 +0800 |
|---|---|---|
| committer | Nick Cao <nickcao@nichi.co> | 2023-02-07 17:16:03 +0800 |
| commit | 82a0b7d7df926b2b4411494dbfb0a92410213714 (patch) | |
| tree | 89fba4547e19b5ae6629dc31c91b78293a6630fe /pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch | |
| parent | 8304c7138e62d3223c5cbc9429806fc6eb04e210 (diff) | |
python311Packages.python-zbar: fix build since Py_SIZE is turned into a function
Python 3.11 turned Py_SIZE into a function, thus Py_SIZE(obj) will be a rvalue,
we need to use Py_SET_SIZE to set size now.
Diffstat (limited to 'pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch')
| -rw-r--r-- | pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch b/pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch new file mode 100644 index 000000000000..11b554151790 --- /dev/null +++ b/pkgs/development/python-modules/python-zbar/0001-python-enum-fix-build-for-Python-3.11.patch @@ -0,0 +1,61 @@ +From 64de7911d2938fc3601fec39c08008465b9d4f6f Mon Sep 17 00:00:00 2001 +From: Nick Cao <nickcao@nichi.co> +Date: Tue, 7 Feb 2023 17:12:50 +0800 +Subject: [PATCH] python: enum: fix build for Python 3.11 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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 + +Adapted from https://github.com/mchehab/zbar/pull/231 + +Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> +Signed-off-by: Nick Cao <nickcao@nichi.co> +--- + python/enum.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/python/enum.c b/python/enum.c +index dfe1b1e..4833a20 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_VERSION_HEX >= 0x030900A4 ++ 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 +@@ -143,7 +147,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_VERSION_HEX >= 0x030900A4 ++ 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.39.1 + |
