summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-02-02 15:03:10 (GMT)
committerGitHub <noreply@github.com>2022-02-02 15:03:10 (GMT)
commitf66c857572a308822c70fd25e0197b6e0dec6e34 (patch)
tree0014ec4456f837b05462e172655e194385e2ec61 /Lib/test
parent08f8301b21648d58d053e1a513db8ed32fbf37dd (diff)
downloadcpython-f66c857572a308822c70fd25e0197b6e0dec6e34.zip
cpython-f66c857572a308822c70fd25e0197b6e0dec6e34.tar.gz
cpython-f66c857572a308822c70fd25e0197b6e0dec6e34.tar.bz2
bpo-45459: Add Py_buffer to limited API (GH-29991)
- [x] ``Py_buffer`` struct - [x] ``PyBuffer_*()`` API functions - [x] ``PyBUF_*`` constants - [x] ``Py_bf_getbuffer`` and ``Py_bf_releasebuffer`` type slots - [x] ``PyMemoryView_FromBuffer()`` API - [x] tests for limited API - [x] ``make regen-limited-abi`` - [x] documentation update - [ ] export ``PyPickleBuffer*()`` API ???
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_stable_abi_ctypes.py12
-rw-r--r--Lib/test/test_xxlimited.py11
2 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py
index 9fd6b14..a49235b 100644
--- a/Lib/test/test_stable_abi_ctypes.py
+++ b/Lib/test/test_stable_abi_ctypes.py
@@ -28,6 +28,14 @@ SYMBOL_NAMES = (
"PyBaseObject_Type",
"PyBool_FromLong",
"PyBool_Type",
+ "PyBuffer_FillContiguousStrides",
+ "PyBuffer_FillInfo",
+ "PyBuffer_FromContiguous",
+ "PyBuffer_GetPointer",
+ "PyBuffer_IsContiguous",
+ "PyBuffer_Release",
+ "PyBuffer_SizeFromFormat",
+ "PyBuffer_ToContiguous",
"PyByteArrayIter_Type",
"PyByteArray_AsString",
"PyByteArray_Concat",
@@ -381,6 +389,7 @@ SYMBOL_NAMES = (
"PyMemberDescr_Type",
"PyMember_GetOne",
"PyMember_SetOne",
+ "PyMemoryView_FromBuffer",
"PyMemoryView_FromMemory",
"PyMemoryView_FromObject",
"PyMemoryView_GetContiguous",
@@ -470,8 +479,10 @@ SYMBOL_NAMES = (
"PyObject_CallNoArgs",
"PyObject_CallObject",
"PyObject_Calloc",
+ "PyObject_CheckBuffer",
"PyObject_CheckReadBuffer",
"PyObject_ClearWeakRefs",
+ "PyObject_CopyData",
"PyObject_DelItem",
"PyObject_DelItemString",
"PyObject_Dir",
@@ -489,6 +500,7 @@ SYMBOL_NAMES = (
"PyObject_GetAIter",
"PyObject_GetAttr",
"PyObject_GetAttrString",
+ "PyObject_GetBuffer",
"PyObject_GetItem",
"PyObject_GetIter",
"PyObject_HasAttr",
diff --git a/Lib/test/test_xxlimited.py b/Lib/test/test_xxlimited.py
index e3f521d..6dbfb3f 100644
--- a/Lib/test/test_xxlimited.py
+++ b/Lib/test/test_xxlimited.py
@@ -58,6 +58,17 @@ class TestXXLimited(CommonTests, unittest.TestCase):
with self.assertRaises(self.module.Error):
raise self.module.Error
+ def test_buffer(self):
+ xxo = self.module.Xxo()
+ self.assertEqual(xxo.x_exports, 0)
+ b1 = memoryview(xxo)
+ self.assertEqual(xxo.x_exports, 1)
+ b2 = memoryview(xxo)
+ self.assertEqual(xxo.x_exports, 2)
+ b1[0] = 1
+ self.assertEqual(b1[0], 1)
+ self.assertEqual(b2[0], 1)
+
class TestXXLimited35(CommonTests, unittest.TestCase):
module = xxlimited_35