Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def test_bad_constructor(self):
self.assertRaises(TypeError, array.array, 'xx')
self.assertRaises(ValueError, array.array, 'x')

@support.cpython_only
def test_immutable(self):
Comment thread
erlend-aasland marked this conversation as resolved.
with self.assertRaises(TypeError):
array.array.foo = 1

def test_empty(self):
# Exercise code for handling zero-length arrays
a = array.array('B')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Apply :const:`Py_TPFLAGS_IMMUTABLETYPE` flag to :class:`array.array`. Patch by
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
Erlend E. Aasland.
3 changes: 2 additions & 1 deletion Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2847,7 +2847,8 @@ static PyType_Slot array_slots[] = {
static PyType_Spec array_spec = {
.name = "array.array",
.basicsize = sizeof(arrayobject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_IMMUTABLETYPE),
.slots = array_slots,
};

Expand Down