diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2020-01-29 11:57:05 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-02-05 10:16:52 +0100 |
commit | 821480b1f0d0cfb59df427315c29c364096818c4 (patch) | |
tree | c033e26734c0ea19081347651ae6425cd5870974 /sources/pyside2/tests | |
parent | 95ec3e2ca7a0a06c0750f78e0c4e44e09f5347f2 (diff) |
Fix PyBuffer interface for QByteArray
For the limited API, properly implement the PyBUF_ND flag (shape
requested).
Otherwise, use the convenience function PyBuffer_FillInfo() to
properly populate the view.
Fixes: PYSIDE-1204
Change-Id: I2a4c81885cf49b25c89823577c0d7ee2f2707b87
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r-- | sources/pyside2/tests/QtCore/qbytearray_test.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sources/pyside2/tests/QtCore/qbytearray_test.py b/sources/pyside2/tests/QtCore/qbytearray_test.py index dba9ecfea..4760fe20b 100644 --- a/sources/pyside2/tests/QtCore/qbytearray_test.py +++ b/sources/pyside2/tests/QtCore/qbytearray_test.py @@ -265,6 +265,12 @@ class QByteArraySliceAssignment(unittest.TestCase): b[9:2:-3] = bytearray(py3k.b('XYZ')) self.assertEqual(b, py3k.b('012Z45Y78X')) + def testBufferProtocol(self): + orig_bytes = py3k.b('0123456789') + byte_array = QByteArray(orig_bytes) + actual_bytes = bytes(byte_array) + self.assertEqual(orig_bytes, actual_bytes) + if __name__ == '__main__': unittest.main() |