Merge pull request #1709 from jeremyd2019/wxpybuffer-python2

Try both old and new buffer protocols on python2.7
This commit is contained in:
Robin Dunn
2020-07-16 19:23:14 -07:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -31,8 +31,9 @@ public:
#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)
@@ -41,7 +42,6 @@ public:
m_len = view.len;
PyBuffer_Release(&view);
return true;
#endif
}

View File

@@ -226,7 +226,7 @@ def __init_resources():
"""
ADD_FILE_TO_MEMFS = """\
wx.MemoryFSHandler.AddFile('XRC/%(memoryPath)s/%(filename)s', bytearray(%(filename)s))
wx.MemoryFSHandler.AddFile('XRC/%(memoryPath)s/%(filename)s', memoryview(%(filename)s))
"""
LOAD_RES_MEMFS = """\