mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
#3946 fix PyObject_CheckBuffer on a memoryview object
reviewed by Antoine
This commit is contained in:
parent
8a1b689e85
commit
60320cb3e4
3 changed files with 6 additions and 3 deletions
|
@ -268,16 +268,16 @@ int
|
|||
PyObject_CheckReadBuffer(PyObject *obj)
|
||||
{
|
||||
PyBufferProcs *pb = obj->ob_type->tp_as_buffer;
|
||||
Py_buffer view;
|
||||
|
||||
if (pb == NULL ||
|
||||
pb->bf_getbuffer == NULL)
|
||||
return 0;
|
||||
if ((*pb->bf_getbuffer)(obj, NULL, PyBUF_SIMPLE) == -1) {
|
||||
if ((*pb->bf_getbuffer)(obj, &view, PyBUF_SIMPLE) == -1) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
if (*pb->bf_releasebuffer != NULL)
|
||||
(*pb->bf_releasebuffer)(obj, NULL);
|
||||
PyBuffer_Release(&view);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue