[Python-modules-commits] [sortedcontainers] 01/05: Import sortedcontainers_1.5.7.orig.tar.gz
Sandro Tosi
morph at moszumanska.debian.org
Thu Jan 5 19:44:59 UTC 2017
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository sortedcontainers.
commit a08a3266bb1a46361a3fe71a4e1099ee3d9b2c4d
Author: Sandro Tosi <morph at debian.org>
Date: Thu Jan 5 14:38:55 2017 -0500
Import sortedcontainers_1.5.7.orig.tar.gz
---
HISTORY.rst | 8 ++++++++
sortedcontainers/__init__.py | 4 ++--
sortedcontainers/sortedlist.py | 6 ++++++
tests/test_coverage_sortedlist.py | 5 +++++
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/HISTORY.rst b/HISTORY.rst
index e9450b0..dbdc575 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,6 +1,14 @@
Sorted Containers Release History
=================================
+1.5.7 (2016-12-22)
+------------------
+
+**Bugfixes**
+
+* Changed ``SortedList.__setitem__`` to support slices with stop less than
+ start and step equal one.
+
1.5.6 (2016-12-09)
------------------
diff --git a/sortedcontainers/__init__.py b/sortedcontainers/__init__.py
index 5a7115b..54b2bf6 100644
--- a/sortedcontainers/__init__.py
+++ b/sortedcontainers/__init__.py
@@ -45,8 +45,8 @@ from .sorteddict import SortedDict
__all__ = ['SortedList', 'SortedSet', 'SortedDict', 'SortedListWithKey']
__title__ = 'sortedcontainers'
-__version__ = '1.5.6'
-__build__ = 0x010506
+__version__ = '1.5.7'
+__build__ = 0x010507
__author__ = 'Grant Jenks'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2016 Grant Jenks'
diff --git a/sortedcontainers/sortedlist.py b/sortedcontainers/sortedlist.py
index 40c7ea0..b6ba322 100644
--- a/sortedcontainers/sortedlist.py
+++ b/sortedcontainers/sortedlist.py
@@ -746,6 +746,12 @@ class SortedList(MutableSequence):
self._clear()
return self._update(values)
+ if stop < start:
+ # When calculating indices, stop may be less than start.
+ # For example: ...[5:3:1] results in slice(5, 3, 1) which
+ # is a valid but not useful stop index.
+ stop = start
+
if values:
# Check that given values are ordered properly.
diff --git a/tests/test_coverage_sortedlist.py b/tests/test_coverage_sortedlist.py
index 8109199..1fccf63 100644
--- a/tests/test_coverage_sortedlist.py
+++ b/tests/test_coverage_sortedlist.py
@@ -279,6 +279,11 @@ def test_setitem_slice_aliasing():
slt[1:1] = slt
assert slt == [0, 0]
+def test_setitem_empty_slice():
+ sl = SortedList(['a'])
+ sl[1:0] = ['b']
+ assert sl == ['a', 'b']
+
@raises(ValueError)
def test_setitem_slice_bad():
slt = SortedList(range(100), load=17)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sortedcontainers.git
More information about the Python-modules-commits
mailing list