From 73cac2f97dcdb369cbcfc5cf404f4ee296904a7b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 31 May 2019 23:52:40 +0000 Subject: [PATCH] Fix broken Python/C interop on s390x. --- ...he-correct-types-to-PyArg_ParseTuple.patch | 132 ++++++++++++++++++ python-pillow.spec | 7 +- 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 0001-Pass-the-correct-types-to-PyArg_ParseTuple.patch diff --git a/0001-Pass-the-correct-types-to-PyArg_ParseTuple.patch b/0001-Pass-the-correct-types-to-PyArg_ParseTuple.patch new file mode 100644 index 0000000..85bca40 --- /dev/null +++ b/0001-Pass-the-correct-types-to-PyArg_ParseTuple.patch @@ -0,0 +1,132 @@ +From 560bc337314c35c599bf75ef3f925d35dc879245 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Fri, 31 May 2019 05:55:13 -0400 +Subject: [PATCH] Pass the correct types to PyArg_ParseTuple. + +Py_ssize_t uses the 'n' specifier, not 'i'. + +Signed-off-by: Elliott Sales de Andrade +--- + src/_imagingft.c | 2 +- + src/encode.c | 22 +++++++++++----------- + 2 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/src/_imagingft.c b/src/_imagingft.c +index 00c0c517..b604c8b2 100644 +--- a/src/_imagingft.c ++++ b/src/_imagingft.c +@@ -257,7 +257,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw) + return NULL; + } + +- if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|is"PY_ARG_BYTES_LENGTH"i", ++ if (!PyArg_ParseTupleAndKeywords(args, kw, "etn|ns"PY_ARG_BYTES_LENGTH"n", + kwlist, + Py_FileSystemDefaultEncoding, &filename, + &size, &index, &encoding, &font_bytes, +diff --git a/src/encode.c b/src/encode.c +index 6832f90c..40fbd459 100644 +--- a/src/encode.c ++++ b/src/encode.c +@@ -126,7 +126,7 @@ _encode(ImagingEncoderObject* encoder, PyObject* args) + + Py_ssize_t bufsize = 16384; + +- if (!PyArg_ParseTuple(args, "|i", &bufsize)) ++ if (!PyArg_ParseTuple(args, "|n", &bufsize)) + return NULL; + + buf = PyBytes_FromStringAndSize(NULL, bufsize); +@@ -180,7 +180,7 @@ _encode_to_file(ImagingEncoderObject* encoder, PyObject* args) + Py_ssize_t fh; + Py_ssize_t bufsize = 16384; + +- if (!PyArg_ParseTuple(args, "i|i", &fh, &bufsize)) ++ if (!PyArg_ParseTuple(args, "n|n", &fh, &bufsize)) + return NULL; + + /* Allocate an encoder buffer */ +@@ -229,7 +229,7 @@ _setimage(ImagingEncoderObject* encoder, PyObject* args) + x0 = y0 = x1 = y1 = 0; + + /* FIXME: should publish the ImagingType descriptor */ +- if (!PyArg_ParseTuple(args, "O|(iiii)", &op, &x0, &y0, &x1, &y1)) ++ if (!PyArg_ParseTuple(args, "O|(nnnn)", &op, &x0, &y0, &x1, &y1)) + return NULL; + im = PyImaging_AsImaging(op); + if (!im) +@@ -409,7 +409,7 @@ PyImaging_GifEncoderNew(PyObject* self, PyObject* args) + char *rawmode; + Py_ssize_t bits = 8; + Py_ssize_t interlace = 0; +- if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &bits, &interlace)) ++ if (!PyArg_ParseTuple(args, "ss|nn", &mode, &rawmode, &bits, &interlace)) + return NULL; + + encoder = PyImaging_EncoderNew(sizeof(GIFENCODERSTATE)); +@@ -441,7 +441,7 @@ PyImaging_PcxEncoderNew(PyObject* self, PyObject* args) + char *rawmode; + Py_ssize_t bits = 8; + +- if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &bits)) { ++ if (!PyArg_ParseTuple(args, "ss|n", &mode, &rawmode, &bits)) { + return NULL; + } + +@@ -474,7 +474,7 @@ PyImaging_RawEncoderNew(PyObject* self, PyObject* args) + Py_ssize_t stride = 0; + Py_ssize_t ystep = 1; + +- if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &stride, &ystep)) ++ if (!PyArg_ParseTuple(args, "ss|nn", &mode, &rawmode, &stride, &ystep)) + return NULL; + + encoder = PyImaging_EncoderNew(0); +@@ -506,7 +506,7 @@ PyImaging_TgaRleEncoderNew(PyObject* self, PyObject* args) + char *rawmode; + Py_ssize_t ystep = 1; + +- if (!PyArg_ParseTuple(args, "ss|i", &mode, &rawmode, &ystep)) ++ if (!PyArg_ParseTuple(args, "ss|n", &mode, &rawmode, &ystep)) + return NULL; + + encoder = PyImaging_EncoderNew(0); +@@ -567,7 +567,7 @@ PyImaging_ZipEncoderNew(PyObject* self, PyObject* args) + Py_ssize_t compress_type = -1; + char* dictionary = NULL; + Py_ssize_t dictionary_size = 0; +- if (!PyArg_ParseTuple(args, "ss|iii"PY_ARG_BYTES_LENGTH, &mode, &rawmode, ++ if (!PyArg_ParseTuple(args, "ss|nnn"PY_ARG_BYTES_LENGTH, &mode, &rawmode, + &optimize, + &compress_level, &compress_type, + &dictionary, &dictionary_size)) +@@ -717,7 +717,7 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args) + char* rawExif = NULL; + Py_ssize_t rawExifLen = 0; + +- if (!PyArg_ParseTuple(args, "ss|iiiiiiiiO"PY_ARG_BYTES_LENGTH""PY_ARG_BYTES_LENGTH, ++ if (!PyArg_ParseTuple(args, "ss|nnnnnnnnO"PY_ARG_BYTES_LENGTH""PY_ARG_BYTES_LENGTH, + &mode, &rawmode, &quality, + &progressive, &smooth, &optimize, &streamtype, + &xdpi, &ydpi, &subsampling, &qtables, &extra, &extra_size, +@@ -823,7 +823,7 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) + PyObject *keys, *values; + + +- if (! PyArg_ParseTuple(args, "sssisO", &mode, &rawmode, &compname, &fp, &filename, &dir)) { ++ if (! PyArg_ParseTuple(args, "sssnsO", &mode, &rawmode, &compname, &fp, &filename, &dir)) { + return NULL; + } + +@@ -995,7 +995,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) + OPJ_CINEMA_MODE cine_mode; + Py_ssize_t fd = -1; + +- if (!PyArg_ParseTuple(args, "ss|OOOsOIOOOssi", &mode, &format, ++ if (!PyArg_ParseTuple(args, "ss|OOOsOnOOOssn", &mode, &format, + &offset, &tile_offset, &tile_size, + &quality_mode, &quality_layers, &num_resolutions, + &cblk_size, &precinct_size, +-- +2.21.0 + diff --git a/python-pillow.spec b/python-pillow.spec index da68aa7..5a97af6 100644 --- a/python-pillow.spec +++ b/python-pillow.spec @@ -14,13 +14,15 @@ Name: python-%{srcname} Version: 6.0.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Python image processing library # License: see http://www.pythonware.com/products/pil/license.htm License: MIT URL: http://python-pillow.github.io/ Source0: https://github.com/python-pillow/Pillow/archive/%{version}/Pillow-%{version}.tar.gz +# Fix "SystemError: tile cannot extend outside image" on s390x (#1706450) +Patch0001: 0001-Pass-the-correct-types-to-PyArg_ParseTuple.patch BuildRequires: freetype-devel BuildRequires: gcc @@ -301,6 +303,9 @@ popd %changelog +* Fri May 31 2019 Elliott Sales de Andrade - 6.0.0-2 +- Fix broken Python/C interop on s390x + * Tue Apr 02 2019 Sandro Mani - 6.0.0-1 - Update to 6.0.0