From ea616e34f153fa89b1e2832ef8e10c6746d0eda0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 8 Jul 2026 18:59:28 +0300 Subject: [PATCH] [3.13] gh-153210: Restore accidental `array.ArrayType` removal (GH-153261) (#153289) (cherry picked from commit ac2e14b4e29b2d11a14d289969cfffc298ea75d9) --- Lib/test/test_array.py | 5 +++++ Modules/arraymodule.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 322b77463962..331ee27179b8 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -35,6 +35,11 @@ typecodes = 'uwbBhHiIlLfdqQ' 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 8e587af71690..f92b258793ff 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -3282,6 +3282,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) { -- 2.47.3