Skip to content

Commit

Permalink
pythongh-98658: Add __class_getitem__ to array.array
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Oct 25, 2022
1 parent a1a8828 commit b41bf73
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ New Modules
Improved Modules
================

array
-----

* The :class:`array.array` class now supports subscripting, making it a
:term:`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)

asyncio
-------

Expand All @@ -132,7 +138,6 @@ asyncio
and will be removed in Python 3.14.
(Contributed by Kumar Aditya in :gh:`94597`.)


pathlib
-------

Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import unittest
import pickle
from array import array
import copy
from collections import (
defaultdict, deque, OrderedDict, Counter, UserDict, UserList
Expand Down Expand Up @@ -124,7 +125,8 @@ class BaseTest(unittest.TestCase):
ShareableList,
Future, _WorkItem,
Morsel,
DictReader, DictWriter]
DictReader, DictWriter,
array]
if ctypes is not None:
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
if ValueProxy is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The :class:`array.array` class now supports subscripting, making it a
:term:`generic type`.
1 change: 1 addition & 0 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ static PyMethodDef array_methods[] = {
ARRAY_ARRAY_TOBYTES_METHODDEF
ARRAY_ARRAY_TOUNICODE_METHODDEF
ARRAY_ARRAY___SIZEOF___METHODDEF
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL} /* sentinel */
};

Expand Down

0 comments on commit b41bf73

Please sign in to comment.