Skip to content

Commit

Permalink
Try both old and new buffer protocols on python2.7
Browse files Browse the repository at this point in the history
While some objects on 2.7 might only implement the old buffer protocol,
some (notably memoryview) only implement the new buffer protocol, so
both need to be tried.
  • Loading branch information
jeremyd2019 committed Jul 3, 2020
1 parent 961dda6 commit 357a350
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/wxpybuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class wxPyBuffer
#if PY_MAJOR_VERSION < 3
// Old buffer protocol
int rv = PyObject_AsReadBuffer(obj, (const void**)&m_ptr, &m_len);
return rv != -1;
#else
if (rv != -1)
return true;
#endif
// New buffer protocol
Py_buffer view;
if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) != 0)
Expand All @@ -41,7 +42,6 @@ class wxPyBuffer
m_len = view.len;
PyBuffer_Release(&view);
return true;
#endif
}


Expand Down

0 comments on commit 357a350

Please sign in to comment.