Skip to content

Commit ac2e14b

Browse files
authored
gh-153210: Restore accidental array.ArrayType removal (#153261)
1 parent 08759ff commit ac2e14b

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
@@ -31,6 +31,11 @@ def __init__(self, typecode, newarg=None):
3131

3232
class MiscTest(unittest.TestCase):
3333

34+
def test_array_type_importable(self):
35+
from array import ArrayType
36+
37+
self.assertIs(array.array, ArrayType)
38+
3439
def test_array_is_sequence(self):
3540
self.assertIsInstance(array.array("B"), collections.abc.MutableSequence)
3641
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
@@ -3401,6 +3401,12 @@ array_modexec(PyObject *m)
34013401
CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec);
34023402
Py_SET_TYPE(state->ArrayIterType, &PyType_Type);
34033403

3404+
// Older undocumented alias:
3405+
if (PyModule_AddObjectRef(m, "ArrayType",
3406+
(PyObject *)state->ArrayType) < 0) {
3407+
return -1;
3408+
}
3409+
34043410
PyObject *mutablesequence = PyImport_ImportModuleAttrString(
34053411
"collections.abc", "MutableSequence");
34063412
if (!mutablesequence) {

0 commit comments

Comments
 (0)