Skip to content

Commit 557e994

Browse files
[3.15] gh-153210: Restore accidental array.ArrayType removal (GH-153261) (#153274)
gh-153210: Restore accidental `array.ArrayType` removal (GH-153261) (cherry picked from commit ac2e14b) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 7342e01 commit 557e994

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

3939
class MiscTest(unittest.TestCase):
4040

41+
def test_array_type_importable(self):
42+
from array import ArrayType
43+
44+
self.assertIs(array.array, ArrayType)
45+
4146
def test_array_is_sequence(self):
4247
self.assertIsInstance(array.array("B"), collections.abc.MutableSequence)
4348
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
@@ -3502,6 +3502,12 @@ array_modexec(PyObject *m)
35023502
CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec);
35033503
Py_SET_TYPE(state->ArrayIterType, &PyType_Type);
35043504

3505+
// Older undocumented alias:
3506+
if (PyModule_AddObjectRef(m, "ArrayType",
3507+
(PyObject *)state->ArrayType) < 0) {
3508+
return -1;
3509+
}
3510+
35053511
PyObject *mutablesequence = PyImport_ImportModuleAttrString(
35063512
"collections.abc", "MutableSequence");
35073513
if (!mutablesequence) {

0 commit comments

Comments
 (0)