From cee68fa1d1f964a5859a0b09fa4aad902273567f Mon Sep 17 00:00:00 2001 From: Ankith Date: Thu, 28 Dec 2023 23:25:58 +0530 Subject: [PATCH] Call PyObject_GetBuffer directly, fix pypy fail --- src_c/base.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src_c/base.c b/src_c/base.c index a9cd9d7286..97d22c0a04 100644 --- a/src_c/base.c +++ b/src_c/base.c @@ -1148,12 +1148,9 @@ pgObject_GetBuffer(PyObject *obj, pg_buffer *pg_view_p, int flags) flags |= PyBUF_PYGAME; #endif - if (PyObject_CheckBuffer(obj)) { + if (PyObject_GetBuffer(obj, view_p, flags) == 0) { char *fchar_p; - if (PyObject_GetBuffer(obj, view_p, flags)) { - return -1; - } pg_view_p->release_buffer = PyBuffer_Release; /* Check the format is a numeric type or pad bytes @@ -1225,6 +1222,9 @@ pgObject_GetBuffer(PyObject *obj, pg_buffer *pg_view_p, int flags) } success = 1; } + else { + PyErr_Clear(); + } if (!success && pgGetArrayStruct(obj, &cobj, &inter_p) == 0) { if (pgArrayStruct_AsBuffer(pg_view_p, cobj, inter_p, flags)) {