From 7cd707c485f814af7dda741bc9a275269d3fc765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= Date: Sat, 9 Jan 2021 11:13:56 +0100 Subject: [PATCH] Add patch to fix the import error occurring with Python 3.10 Fix: rhbz#1904379 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert-André Mauchin --- ...Module_AddObject-fix-for-Python-3.10.patch | 104 ++++++++++++++++++ python-pillow.spec | 10 +- 2 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 0001-PyModule_AddObject-fix-for-Python-3.10.patch diff --git a/0001-PyModule_AddObject-fix-for-Python-3.10.patch b/0001-PyModule_AddObject-fix-for-Python-3.10.patch new file mode 100644 index 0000000..df4b78c --- /dev/null +++ b/0001-PyModule_AddObject-fix-for-Python-3.10.patch @@ -0,0 +1,104 @@ +From cf190a3c2f166cf0a7dd004fee4b242ea29bf1f4 Mon Sep 17 00:00:00 2001 +From: Andrew Murray +Date: Sat, 9 Jan 2021 11:33:26 +1100 +Subject: [PATCH 2/2] PyModule_AddObject fix for Python 3.10 + +--- + src/_imaging.c | 21 +++++++++++++++------ + src/_webp.c | 14 ++++++++++---- + 2 files changed, 25 insertions(+), 10 deletions(-) + +diff --git a/src/_imaging.c b/src/_imaging.c +index a8741f6ad3..01dd22486e 100644 +--- a/src/_imaging.c ++++ b/src/_imaging.c +@@ -4172,26 +4172,32 @@ setup_module(PyObject* m) { + } + #endif + ++ PyObject *have_libjpegturbo; + #ifdef LIBJPEG_TURBO_VERSION +- PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_True); ++ have_libjpegturbo = Py_True; + #define tostr1(a) #a + #define tostr(a) tostr1(a) + PyDict_SetItemString(d, "libjpeg_turbo_version", PyUnicode_FromString(tostr(LIBJPEG_TURBO_VERSION))); + #undef tostr + #undef tostr1 + #else +- PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_False); +-#endif ++ have_libjpegturbo = Py_False; ++ #endif ++ Py_INCREF(have_libjpegturbo); ++ PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", have_libjpegturbo); + ++ PyObject *have_libimagequant; + #ifdef HAVE_LIBIMAGEQUANT +- PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_True); ++ have_libimagequant = Py_True; + { + extern const char* ImagingImageQuantVersion(void); + PyDict_SetItemString(d, "imagequant_version", PyUnicode_FromString(ImagingImageQuantVersion())); + } + #else +- PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_False); ++ have_libimagequant = Py_False; + #endif ++ Py_INCREF(have_libimagequant); ++ PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", have_libimagequant); + + #ifdef HAVE_LIBZ + /* zip encoding strategies */ +@@ -4222,11 +4228,14 @@ setup_module(PyObject* m) { + } + #endif + ++ PyObject *have_xcb; + #ifdef HAVE_XCB +- PyModule_AddObject(m, "HAVE_XCB", Py_True); ++ have_xcb = Py_True; + #else +- PyModule_AddObject(m, "HAVE_XCB", Py_False); ++ have_xcb = Py_False; + #endif ++ Py_INCREF(have_xcb); ++ PyModule_AddObject(m, "HAVE_XCB", have_xcb); + + PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version)); + +diff --git a/src/_webp.c b/src/_webp.c +index c7875fa368..4d51d99dfa 100644 +--- a/src/_webp.c ++++ b/src/_webp.c +@@ -861,19 +861,25 @@ static PyMethodDef webpMethods[] = + }; + + void addMuxFlagToModule(PyObject* m) { ++ PyObject *have_webpmux; + #ifdef HAVE_WEBPMUX +- PyModule_AddObject(m, "HAVE_WEBPMUX", Py_True); ++ have_webpmux = Py_True; + #else +- PyModule_AddObject(m, "HAVE_WEBPMUX", Py_False); ++ have_webpmux = Py_False; + #endif ++ Py_INCREF(have_webpmux); ++ PyModule_AddObject(m, "HAVE_WEBPMUX", have_webpmux); + } + + void addAnimFlagToModule(PyObject* m) { ++ PyObject *have_webpanim; + #ifdef HAVE_WEBPANIM +- PyModule_AddObject(m, "HAVE_WEBPANIM", Py_True); ++ have_webpanim = Py_True; + #else +- PyModule_AddObject(m, "HAVE_WEBPANIM", Py_False); ++ have_webpanim = Py_False; + #endif ++ Py_INCREF(have_webpanim); ++ PyModule_AddObject(m, "HAVE_WEBPANIM", have_webpanim); + } + + void addTransparencyFlagToModule(PyObject* m) { + diff --git a/python-pillow.spec b/python-pillow.spec index c5144fc..634c8a4 100644 --- a/python-pillow.spec +++ b/python-pillow.spec @@ -8,7 +8,7 @@ Name: python-%{srcname} Version: 8.1.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Python image processing library # License: see http://www.pythonware.com/products/pil/license.htm @@ -20,6 +20,9 @@ Source0: https://github.com/python-pillow/Pillow/archive/%{version}/Pillo Patch0: python-pillow_spinxwarn.patch # Drop sphinx-issues requirement, it's not packaged for Fedora Patch1: python-pillow_sphinx-issues.patch +# PyModule_AddObject fix for Python 3.10 +# https://github.com/python-pillow/Pillow/pull/5194 +Patch2: 0001-PyModule_AddObject-fix-for-Python-3.10.patch BuildRequires: freetype-devel BuildRequires: gcc @@ -153,7 +156,6 @@ pushd build/%py3_libbuilddir PYTHONPATH=$PWD %{__python3} selftest.py popd - %files -n python3-%{srcname} %doc README.md CHANGES.rst %license docs/COPYING @@ -188,6 +190,10 @@ popd %changelog +* Sat Jan 09 2021 Robert-André Mauchin - 8.1.0-2 +- Add patch to fix the import error occurring with Python 3.10 +- Fix: rhbz#1904379 + * Sun Jan 03 2021 Sandro Mani - 8.1.0-1 - Update to 8.1.0