- Fixed bug in association proxy where assigning an empty slice

(e.g. ``x[:] = [...]``) would fail on Py3k.
This commit is contained in:
Mike Bayer
2014-03-04 10:59:27 -05:00
parent f3becf64df
commit d6e8d5eddb
3 changed files with 16 additions and 2 deletions
+6
View File
@@ -14,6 +14,12 @@
.. changelog::
:version: 0.9.4
.. change::
:tags: bug, ext, py3k
Fixed bug in association proxy where assigning an empty slice
(e.g. ``x[:] = [...]``) would fail on Py3k.
.. change::
:tags: bug, general
:tickets: 2979
+3 -2
View File
@@ -540,11 +540,12 @@ class _AssociationList(_AssociationCollection):
stop = index.stop
step = index.step or 1
start = index.start or 0
rng = list(range(index.start or 0, stop, step))
if step == 1:
for i in rng:
del self[index.start]
i = index.start
del self[start]
i = start
for item in value:
self.insert(i, item)
i += 1
+7
View File
@@ -212,6 +212,13 @@ class _CollectionOperations(fixtures.TestBase):
self.assert_(p1.children == after)
self.assert_([c.name for c in p1._children] == after)
p1.children[:] = ['d', 'e']
after = ['d', 'e']
self.assert_(p1.children == after)
self.assert_([c.name for c in p1._children] == after)
p1.children[:] = ['a', 'b']
p1.children += ['c']
after = ['a', 'b', 'c']
self.assert_(p1.children == after)