Skip to content

Commit c05426b

Browse files
committed
Remove array struct support
1 parent 020f6d0 commit c05426b

28 files changed

+26
-1661
lines changed

buildconfig/stubs/pygame/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ from .base import (
6161
BufferError as BufferError,
6262
HAVE_NEWBUF as HAVE_NEWBUF,
6363
error as error,
64-
get_array_interface as get_array_interface,
6564
get_error as get_error,
6665
get_init as get_init,
6766
get_sdl_byteorder as get_sdl_byteorder,

buildconfig/stubs/pygame/base.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ def set_error(error_msg: str, /) -> None: ...
1616
def get_sdl_version(linked: bool = True) -> Tuple[int, int, int]: ...
1717
def get_sdl_byteorder() -> int: ...
1818
def register_quit(callable: Callable[[], Any], /) -> None: ...
19-
20-
# undocumented part of pygame API, kept here to make stubtest happy
21-
def get_array_interface(arg: Any, /) -> dict: ...

buildconfig/stubs/pygame/bufferproxy.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class BufferProxy:
77
# possibly going to be deprecated/removed soon, in which case these
88
# typestubs must be removed too
99
__array_interface__: Dict[str, Any]
10-
__array_struct__: Any
1110
@overload
1211
def __init__(self) -> None: ...
1312
@overload

buildconfig/stubs/pygame/color.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class Color(Collection[int]):
2222
hsla: Tuple[float, float, float, float]
2323
i1i2i3: Tuple[float, float, float]
2424
__hash__: None # type: ignore
25-
__array_struct__: Any
2625
@overload
2726
def __init__(self, r: int, g: int, b: int, a: int = 255) -> None: ...
2827
@overload

buildconfig/stubs/pygame/mixer.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class Sound:
6161
# possibly going to be deprecated/removed soon, in which case these
6262
# typestubs must be removed too
6363
__array_interface__: Dict[str, Any]
64-
__array_struct__: Any
6564
def stop(self) -> None: ...
6665
def fadeout(self, time: int, /) -> None: ...
6766
def set_volume(self, value: float, /) -> None: ...
@@ -70,7 +69,6 @@ class Sound:
7069
def get_length(self) -> float: ...
7170
def get_raw(self) -> bytes: ...
7271

73-
7472
class Channel:
7573
def __init__(self, id: int) -> None: ...
7674
@property

buildconfig/stubs/pygame/pixelarray.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ class PixelArray:
1010
ndim: int
1111
shape: Tuple[int, ...]
1212
strides: Tuple[int, ...]
13-
# possibly going to be deprecated/removed soon, in which case these
14-
# typestubs must be removed too
1513
__array_interface__: Dict[str, Any]
16-
__array_struct__: Any
1714
def __init__(self, surface: Surface) -> None: ...
1815
def __enter__(self) -> PixelArray: ...
1916
def __exit__(self, *args, **kwargs) -> None: ...

docs/reST/c_api/base.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,14 @@ C header: src_c/include/pygame.h
124124
Return a Python array interface object representation of buffer *view_p*.
125125
On failure raise a Python exception and return *NULL*.
126126
127-
.. c:function:: PyObject* pgBuffer_AsArrayStruct(Py_buffer *view_p)
128-
129-
Return a Python array struct object representation of buffer *view_p*.
130-
On failure raise a Python exception and return *NULL*.
131-
132127
.. c:function:: int pgObject_GetBuffer(PyObject *obj, pg_buffer *pg_view_p, int flags)
133128
134129
Request a buffer for object *obj*.
135130
Argument *flags* are PyBUF options.
136131
Return the buffer description in *pg_view_p*.
137-
An object may support the Python buffer interface, the NumPy array interface,
138-
or the NumPy array struct interface.
139-
Return ``0`` on success, raise a Python exception and return ``-1`` on failure.
132+
An object may support the Python buffer interface or the NumPy python
133+
object array interface. Return ``0`` on success, raise a Python exception
134+
and return ``-1`` on failure.
140135
141136
.. c:function:: void pgBuffer_Release(Pg_buffer *pg_view_p)
142137

docs/reST/ref/freetype.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ loaded. This module must be imported explicitly to be used. ::
506506
| :sl:`Render text into an array of ints`
507507
| :sg:`render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> Rect`
508508
509-
Render to an array object exposing an array struct interface. The array
509+
Render to an array object exposing the buffer protocol. The array
510510
must be two dimensional with integer items. The default *dest* value,
511511
``None``, is equivalent to position (0, 0). See :meth:`render_to`.
512512
As with the other render methods, *text* can be ``None`` to

docs/reST/ref/pixelarray.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
for assignment. A pixel array sliced on a single column or row
1818
returns a one dimensional pixel array. Arithmetic and other operations
1919
are not supported. A pixel array can be safely assigned to itself.
20-
Finally, pixel arrays export an array struct interface, allowing
21-
them to interact with :mod:`pygame.pixelcopy` methods and NumPy
22-
arrays.
20+
Finally, pixel arrays export the buffer protocol as well as the python
21+
array interface, allowing them to interact with :mod:`pygame.pixelcopy`
22+
methods and NumPy arrays.
2323

2424
A PixelArray pixel item can be assigned a raw integer values, a
2525
:class:`pygame.Color` instance, or a (r, g, b[, a]) tuple.
@@ -100,6 +100,8 @@
100100
copying is implemented it is suggested PixelArray to PixelArray copies be
101101
only between surfaces of identical format.
102102

103+
.. versionchanged:: 2.5.0 Removed array struct support
104+
103105
.. versionaddedold:: 1.9.4
104106

105107
- close() method was added. For explicitly cleaning up.

docs/reST/ref/pixelcopy.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,18 @@
99
| :sl:`pygame module for general pixel array copying`
1010
1111
The ``pygame.pixelcopy`` module contains functions for copying between
12-
surfaces and objects exporting an array structure interface. It is a backend
13-
for :mod:`pygame.surfarray`, adding NumPy support. But pixelcopy is more
14-
general, and intended for direct use.
15-
16-
The array struct interface exposes an array's data in a standard way.
17-
It was introduced in NumPy. In Python 2.7 and above it is replaced by the
18-
new buffer protocol, though the buffer protocol is still a work in progress.
19-
The array struct interface, on the other hand, is stable and works with earlier
20-
Python versions. So for now the array struct interface is the predominate way
21-
pygame handles array introspection.
12+
surfaces and objects exporting the buffer protocol or the python array
13+
interface. It is a backend for :mod:`pygame.surfarray`, which adds NumPy
14+
support. But pixelcopy is more general, and intended for direct use.
2215

2316
For 2d arrays of integer pixel values, the values are mapped to the
2417
pixel format of the related surface. To get the actual color of a pixel
2518
value use :meth:`pygame.Surface.unmap_rgb`. 2d arrays can only be used
2619
directly between surfaces having the same pixel layout.
2720

28-
New in pygame 1.9.2.
21+
.. versionchanged:: 2.5.0 Removed array struct support
22+
23+
.. versionaddedold:: 1.9.2
2924

3025
.. function:: surface_to_array
3126

0 commit comments

Comments
 (0)