diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 322b77463962a3..331ee27179b826 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -35,6 +35,11 @@ def __init__(self, typecode, newarg=None): class MiscTest(unittest.TestCase): + def test_array_type_importable(self): + from array import ArrayType + + self.assertIs(array.array, ArrayType) + def test_array_is_sequence(self): self.assertIsInstance(array.array("B"), collections.abc.MutableSequence) self.assertIsInstance(array.array("B"), collections.abc.Reversible) diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 8833ea2c0bf0f2..2f578725808742 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -3262,6 +3262,12 @@ array_modexec(PyObject *m) CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec); Py_SET_TYPE(state->ArrayIterType, &PyType_Type); + // Older undocumented alias: + if (PyModule_AddObjectRef(m, "ArrayType", + (PyObject *)state->ArrayType) < 0) { + return -1; + } + PyObject *mutablesequence = _PyImport_GetModuleAttrString( "collections.abc", "MutableSequence"); if (!mutablesequence) {