Skip to content

Commit ea616e3

Browse files
authored
[3.13] gh-153210: Restore accidental array.ArrayType removal (GH-153261) (#153289)
(cherry picked from commit ac2e14b)
1 parent 3fc52b3 commit ea616e3

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/test/test_array.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def __init__(self, typecode, newarg=None):
3535

3636
class MiscTest(unittest.TestCase):
3737

38+
def test_array_type_importable(self):
39+
from array import ArrayType
40+
41+
self.assertIs(array.array, ArrayType)
42+
3843
def test_array_is_sequence(self):
3944
self.assertIsInstance(array.array("B"), collections.abc.MutableSequence)
4045
self.assertIsInstance(array.array("B"), collections.abc.Reversible)

Modules/arraymodule.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,12 @@ array_modexec(PyObject *m)
32823282
CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec);
32833283
Py_SET_TYPE(state->ArrayIterType, &PyType_Type);
32843284

3285+
// Older undocumented alias:
3286+
if (PyModule_AddObjectRef(m, "ArrayType",
3287+
(PyObject *)state->ArrayType) < 0) {
3288+
return -1;
3289+
}
3290+
32853291
PyObject *mutablesequence = _PyImport_GetModuleAttrString(
32863292
"collections.abc", "MutableSequence");
32873293
if (!mutablesequence) {

0 commit comments

Comments
 (0)