Skip to content

Commit ad966dc

Browse files
committed
Revert Python-space ctypes tests
This reverts commit 9d454de. This reverts commit 1fea8e5.
1 parent de09bbe commit ad966dc

3 files changed

Lines changed: 1 addition & 70 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"BrokenIter",
7070
"in_systemd_nspawn_sync_suppressed",
7171
"run_no_yield_async_fn", "run_yielding_async_fn", "async_yield",
72-
"reset_code", "on_github_actions", "ctypes_py_buffer",
72+
"reset_code", "on_github_actions"
7373
]
7474

7575

@@ -3272,47 +3272,3 @@ def linked_to_musl():
32723272
return _linked_to_musl
32733273
_linked_to_musl = tuple(map(int, version.split('.')))
32743274
return _linked_to_musl
3275-
3276-
3277-
try:
3278-
import ctypes
3279-
3280-
class _py_buffer(ctypes.Structure):
3281-
_fields_ = [
3282-
("buf", ctypes.c_void_p),
3283-
("obj", ctypes.py_object),
3284-
("len", ctypes.c_ssize_t),
3285-
("itemsize", ctypes.c_ssize_t),
3286-
("readonly", ctypes.c_int),
3287-
("ndim", ctypes.c_int),
3288-
("format", ctypes.c_char_p),
3289-
("shape", ctypes.POINTER(ctypes.c_ssize_t)),
3290-
("strides", ctypes.POINTER(ctypes.c_ssize_t)),
3291-
("suboffsets", ctypes.POINTER(ctypes.c_ssize_t)),
3292-
("internal", ctypes.c_void_p),
3293-
]
3294-
except ImportError:
3295-
_py_buffer = None
3296-
3297-
3298-
@contextlib.contextmanager
3299-
def ctypes_py_buffer(ob, flags=inspect.BufferFlags.SIMPLE):
3300-
"""
3301-
Safely acquire a `Py_buffer` as a ctypes struct.
3302-
3303-
`ob` must implement the buffer protocol, and the retrieved buffer is
3304-
released on exit of the context manager.
3305-
3306-
Skips any test using it if `ctypes` is unavailable.
3307-
"""
3308-
from .import_helper import import_module
3309-
3310-
ctypes = import_module("ctypes")
3311-
buf = _py_buffer()
3312-
ctypes.pythonapi.PyObject_GetBuffer(ctypes.py_object(ob),
3313-
ctypes.byref(buf),
3314-
ctypes.c_int(flags))
3315-
try:
3316-
yield buf
3317-
finally:
3318-
ctypes.pythonapi.PyBuffer_Release(ctypes.byref(buf))

Lib/test/test_array.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from test.support import import_helper
99
from test.support import os_helper
1010
from test.support import _2G
11-
from test.support import ctypes_py_buffer
1211
import weakref
1312
import pickle
1413
import operator
@@ -68,21 +67,6 @@ def test_empty(self):
6867
a += a
6968
self.assertEqual(len(a), 0)
7069

71-
def test_empty_alignment(self):
72-
# gh-140557: pointer alignment of empty allocation
73-
ctypes = import_helper.import_module("ctypes")
74-
self.enterContext(warnings.catch_warnings())
75-
warnings.filterwarnings(
76-
"ignore",
77-
message="The 'u' type code is deprecated and "
78-
"will be removed in Python 3.16",
79-
category=DeprecationWarning)
80-
max_align = ctypes.alignment(ctypes.c_longdouble)
81-
for typecode in typecodes:
82-
a = array.array(typecode)
83-
with ctypes_py_buffer(a) as buf:
84-
self.assertEqual(buf.buf % max_align, 0)
85-
8670

8771
# Machine format codes.
8872
#

Lib/test/test_builtin.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from test.support.testcase import ComplexesAreIdenticalMixin
3939
from test.support.warnings_helper import check_warnings
4040
from test.support import requires_IEEE_754
41-
from test.support import ctypes_py_buffer
4241
from unittest.mock import MagicMock, patch
4342
try:
4443
import pty, signal
@@ -2428,14 +2427,6 @@ def iterator():
24282427
yield b'B'
24292428
self.assertEqual(bytearray(b'A,B'), array.join(iterator()))
24302429

2431-
def test_bytearray_empty_alignment(self):
2432-
# gh-140557: alignment of pointer in empty allocation
2433-
ctypes = import_module("ctypes")
2434-
max_align = ctypes.alignment(ctypes.c_longdouble)
2435-
array = bytearray()
2436-
with ctypes_py_buffer(array) as buf:
2437-
self.assertEqual(buf.buf % max_align, 0)
2438-
24392430
def test_construct_singletons(self):
24402431
for const in None, Ellipsis, NotImplemented:
24412432
tp = type(const)

0 commit comments

Comments
 (0)