Skip to content

Commit 81acbbb

Browse files
committed
Merge tag '0.5.4' into maintenance-0.6
2 parents 1fa5818 + 2ba2a29 commit 81acbbb

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGES.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Changelog
44
Version 0.6.1
55
-------------
66

7-
To be released.
7+
To be released
8+
9+
- Made `nirum.datastructures.List` to copy the given value so that
10+
it doesn't refer given value's state and is immutable.
811

912

1013
Version 0.6.0
@@ -72,6 +75,15 @@ Released on July 11, 2017.
7275
.. _nirum-python-wsgi: https://github.com/spoqa/nirum-python-wsgi
7376

7477

78+
Version 0.5.4
79+
-------------
80+
81+
Released on December 9, 2017.
82+
83+
- Made `nirum.datastructures.List` to copy the given value so that
84+
it doesn't refer given value's state and is immutable.
85+
86+
7587
Version 0.5.3
7688
-------------
7789

nirum/datastructures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __repr__(self):
5454
class List(collections.Sequence):
5555

5656
def __init__(self, items):
57-
self.items = items
57+
self.items = list(items)
5858

5959
def __getitem__(self, index):
6060
return self.items[index]

tests/datastructures_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,12 @@ def test_list():
8888
assert immutable_list.count(1) == 1
8989
assert immutable_list.count(2) == 1
9090
assert immutable_list.count(3) == 0
91+
92+
93+
def test_list_immutable():
94+
mutable_list = [1, 2]
95+
immutable_list = List(mutable_list)
96+
mutable_list.append(3)
97+
assert immutable_list.items != mutable_list
98+
assert immutable_list.items == [1, 2]
99+
assert mutable_list == [1, 2, 3]

0 commit comments

Comments
 (0)