8000 gh-98658: Add __class_getitem__ to array.array (#98661) · python/cpython@5cf317a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5cf317a

Browse files
gh-98658: Add __class_getitem__ to array.array (#98661)
Closes #98658
1 parent 7640ede commit 5cf317a

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

Doc/whatsnew/3.12.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ New Modules
118118
Improved Modules
119119
================
120120

121+
array
122+
-----
123+
124+
* The :class:`array.array` class now supports subscripting, making it a
125+
:term:`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)
126+
121127
asyncio
122128
-------
123129

@@ -141,7 +147,6 @@ asyncio
141147
and will be removed in Python 3.14.
142148
(Contributed by Kumar Aditya in :gh:`94597`.)
143149

144-
145150
pathlib
146151
-------
147152

Lib/test/test_genericalias.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import unittest
44
import pickle
5+
from array import array
56
import copy
67
from collections import (
78
defaultdict, deque, OrderedDict, Counter, UserDict, UserList
@@ -124,7 +125,8 @@ class BaseTest(unittest.TestCase):
124125
ShareableList,
125126
Future, _WorkItem,
126127
Morsel,
127-
DictReader, DictWriter]
128+
DictReader, DictWriter,
129+
array]
128130
if ctypes is not None:
129131
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
130132
if ValueProxy is not None:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The :class:`array.array` class now supports subscripting, making it a
2+
:term:`generic type`.

Modules/arraymodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,7 @@ static PyMethodDef array_methods[] = {
23032303
ARRAY_ARRAY_TOBYTES_METHODDEF
23042304
ARRAY_ARRAY_TOUNICODE_METHODDEF
23052305
ARRAY_ARRAY___SIZEOF___METHODDEF
2306+
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
23062307
{NULL, NULL} /* sentinel */
23072308
};
23082309

0 commit comments

Comments
 (0)
0