From 310f625e60997e69a7f94fa95deb360f0b241897 Mon Sep 17 00:00:00 2001 From: Aleksandr Karpinskii Date: Tue, 17 Sep 2024 15:25:09 +0200 Subject: [PATCH] Remove obsolete PyImaging_CheckBuffer and PyImaging_GetBuffer --- src/_imaging.c | 22 +++------------------- src/map.c | 10 ++-------- src/path.c | 10 ++-------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/_imaging.c b/src/_imaging.c index c100b103d..5775e9ad6 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -198,22 +198,6 @@ ImagingSectionLeave(ImagingSectionCookie *cookie) { PyEval_RestoreThread((PyThreadState *)*cookie); } -/* -------------------------------------------------------------------- */ -/* BUFFER HANDLING */ -/* -------------------------------------------------------------------- */ -/* Python compatibility API */ - -int -PyImaging_CheckBuffer(PyObject *buffer) { - return PyObject_CheckBuffer(buffer); -} - -int -PyImaging_GetBuffer(PyObject *buffer, Py_buffer *view) { - /* must call check_buffer first! */ - return PyObject_GetBuffer(buffer, view, PyBUF_SIMPLE); -} - /* -------------------------------------------------------------------- */ /* EXCEPTION REROUTING */ /* -------------------------------------------------------------------- */ @@ -4188,19 +4172,19 @@ extern PyObject * PyImaging_GrabScreenX11(PyObject *self, PyObject *args); #endif -/* Experimental path stuff (in path.c) */ +/* Path object (in path.c) */ extern PyObject * PyPath_Create(ImagingObject *self, PyObject *args); -/* Experimental outline stuff (in outline.c) */ +/* Outline object (in outline.c) */ extern PyObject * PyOutline_Create(ImagingObject *self, PyObject *args); +/* MapBuffer implementation (in map.c) */ extern PyObject * PyImaging_MapBuffer(PyObject *self, PyObject *args); static PyMethodDef functions[] = { - /* Object factories */ {"alpha_composite", (PyCFunction)_alpha_composite, METH_VARARGS}, {"blend", (PyCFunction)_blend, METH_VARARGS}, diff --git a/src/map.c b/src/map.c index 2fcaa74d2..ee0848cfb 100644 --- a/src/map.c +++ b/src/map.c @@ -20,12 +20,6 @@ #include "libImaging/Imaging.h" -/* compatibility wrappers (defined in _imaging.c) */ -extern int -PyImaging_CheckBuffer(PyObject *buffer); -extern int -PyImaging_GetBuffer(PyObject *buffer, Py_buffer *view); - extern PyObject * PyImagingNew(Imaging im); @@ -75,7 +69,7 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) { return NULL; } - if (!PyImaging_CheckBuffer(target)) { + if (!PyObject_CheckBuffer(target)) { PyErr_SetString(PyExc_TypeError, "expected string or buffer"); return NULL; } @@ -103,7 +97,7 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) { } /* check buffer size */ - if (PyImaging_GetBuffer(target, &view) < 0) { + if (PyObject_GetBuffer(target, &view, PyBUF_SIMPLE) < 0) { return NULL; } diff --git a/src/path.c b/src/path.c index c9c2d61ef..50ea57997 100644 --- a/src/path.c +++ b/src/path.c @@ -28,12 +28,6 @@ #include "libImaging/Imaging.h" #include "thirdparty/pythoncapi_compat.h" -/* compatibility wrappers (defined in _imaging.c) */ -extern int -PyImaging_CheckBuffer(PyObject *buffer); -extern int -PyImaging_GetBuffer(PyObject *buffer, Py_buffer *view); - /* -------------------------------------------------------------------- */ /* Class */ /* -------------------------------------------------------------------- */ @@ -123,10 +117,10 @@ PyPath_Flatten(PyObject *data, double **pxy) { return path->count; } - if (PyImaging_CheckBuffer(data)) { + if (PyObject_CheckBuffer(data)) { /* Assume the buffer contains floats */ Py_buffer buffer; - if (PyImaging_GetBuffer(data, &buffer) == 0) { + if (PyObject_GetBuffer(data, &buffer, PyBUF_SIMPLE) == 0) { float *ptr = (float *)buffer.buf; n = buffer.len / (2 * sizeof(float)); xy = alloc_array(n);