Skip to content

Commit f98f943

Browse files
[3.14] gh-153210: Restore accidental array.ArrayType removal (GH-153261) (#153275)
gh-153210: Restore accidental `array.ArrayType` removal (GH-153261) (cherry picked from commit ac2e14b) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 2981822 commit f98f943

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
@@ -3295,6 +3295,12 @@ array_modexec(PyObject *m)
32953295
CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec);
32963296
Py_SET_TYPE(state->ArrayIterType, &PyType_Type);
32973297

3298+
// Older undocumented alias:
3299+
if (PyModule_AddObjectRef(m, "ArrayType",
3300+
(PyObject *)state->ArrayType) < 0) {
3301+
return -1;
3302+
}
3303+
32983304
PyObject *mutablesequence = PyImport_ImportModuleAttrString(
32993305
"collections.abc", "MutableSequence");
33003306
if (!mutablesequence) {

0 commit comments

Comments
 (0)