From f7f12ba7f277d4c074382b5434123dc66b8791b8 Mon Sep 17 00:00:00 2001 From: Renaud Aubin Date: Mon, 27 May 2019 22:17:44 +0200 Subject: Implement the Buffer Protocol on VoidPtr Some use cases need direct data access for performance, e.g. initializing QPolygonF data with numpy.frombuffer. Implementing the Buffer Protocol as described in PEP3118 will allow direct data access. Change-Id: I13c46055b1cba115d099f1becb64c4cd04acdf0e Reviewed-by: Christian Tismer --- sources/pyside2/tests/support/voidptr_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/support/voidptr_test.py b/sources/pyside2/tests/support/voidptr_test.py index c04022489..f68217244 100644 --- a/sources/pyside2/tests/support/voidptr_test.py +++ b/sources/pyside2/tests/support/voidptr_test.py @@ -54,6 +54,11 @@ class PySide2Support(unittest.TestCase): # Convert original and new to str self.assertTrue(str(b), str(nba)) + # Modify nba through a memoryview of vp + mv = memoryview(vp) + self.assertFalse(mv.readonly) + mv[6:11] = b'void*' + self.assertEqual(str(ba), str(b"Hello void*")) + if __name__ == '__main__': unittest.main() - -- cgit v1.2.3