Fix broken Python/C interop on s390x.

This commit is contained in:
Elliott Sales de Andrade 2019-05-31 23:52:40 +00:00 committed by Sandro Mani
parent a8bdca92c7
commit 73cac2f97d
2 changed files with 138 additions and 1 deletions

View File

@ -0,0 +1,132 @@
From 560bc337314c35c599bf75ef3f925d35dc879245 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
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 <quantum.analyst@gmail.com>
---
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

View File

@ -14,13 +14,15 @@
Name: python-%{srcname} Name: python-%{srcname}
Version: 6.0.0 Version: 6.0.0
Release: 1%{?dist} Release: 2%{?dist}
Summary: Python image processing library Summary: Python image processing library
# License: see http://www.pythonware.com/products/pil/license.htm # License: see http://www.pythonware.com/products/pil/license.htm
License: MIT License: MIT
URL: http://python-pillow.github.io/ URL: http://python-pillow.github.io/
Source0: https://github.com/python-pillow/Pillow/archive/%{version}/Pillow-%{version}.tar.gz 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: freetype-devel
BuildRequires: gcc BuildRequires: gcc
@ -301,6 +303,9 @@ popd
%changelog %changelog
* Fri May 31 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 6.0.0-2
- Fix broken Python/C interop on s390x
* Tue Apr 02 2019 Sandro Mani <manisandro@gmail.com> - 6.0.0-1 * Tue Apr 02 2019 Sandro Mani <manisandro@gmail.com> - 6.0.0-1
- Update to 6.0.0 - Update to 6.0.0