aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorRenaud Aubin <renaud.aubin@gmail.com>2019-05-27 22:17:44 +0200
committerRenaud Aubin <renaud.aubin@gmail.com>2019-06-05 19:32:44 +0200
commitf7f12ba7f277d4c074382b5434123dc66b8791b8 (patch)
tree64c27f854d22abea1c8684c31f7b7ce1123e3f04 /sources/pyside2/tests
parentf4d1a606a0fe5f15ea89779ca3f1bbb9673c2cc6 (diff)
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 <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/support/voidptr_test.py7
1 files changed, 6 insertions, 1 deletions
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()
-