diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-04 10:59:27 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-04 10:59:27 -0500 |
| commit | d6e8d5eddbca7154d008f7ef49efdc62dded7794 (patch) | |
| tree | f535b34e9e7d3210c57c2cd3038070495e731d42 | |
| parent | f3becf64df3937f70c2d0269255d082b27ec4f2d (diff) | |
| download | sqlalchemy-d6e8d5eddbca7154d008f7ef49efdc62dded7794.tar.gz | |
- Fixed bug in association proxy where assigning an empty slice
(e.g. ``x[:] = [...]``) would fail on Py3k.
| -rw-r--r-- | doc/build/changelog/changelog_09.rst | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 5 | ||||
| -rw-r--r-- | test/ext/test_associationproxy.py | 7 |
3 files changed, 16 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index e11710e61..1591872cd 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -15,6 +15,12 @@ :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 diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index a4786de42..045645f86 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -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 diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index 487850601..6a4de0f74 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -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) |
