Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-98658: Add __class_getitem__ to array.array #98661

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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