Remove obsolete PyImaging_CheckBuffer and PyImaging_GetBuffer

This commit is contained in:
Aleksandr Karpinskii 2024-09-17 15:25:09 +02:00 committed by Александр Карпинский
parent 517c3e1c7f
commit 310f625e60
3 changed files with 7 additions and 35 deletions

View File

@ -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},

View File

@ -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;
}

View File

@ -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);