]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug in association proxy where assigning an empty slice
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Mar 2014 15:59:27 +0000 (10:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Mar 2014 15:59:27 +0000 (10:59 -0500)
(e.g. ``x[:] = [...]``) would fail on Py3k.

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/ext/associationproxy.py
test/ext/test_associationproxy.py

index e11710e61b8d7a624123a546b6d0f10093a5c39f..1591872cdf0735fc42b4e5d86015126defab8377 100644 (file)
 .. 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
index a4786de42d013bc6fb89751e5b36649542253594..045645f866ca10fba53055417a4e74c71ad37544 100644 (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
index 48785060190d9aa82e52c9dd0486f922df5498f2..6a4de0f746266f05bb49225c44839644c7b15c1c 100644 (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)