瀏覽代碼

Fix len() sometimes raising ValueError on empty node lists (fixes #174)

tags/v0.5
Ben Kurtovic 7 年之前
父節點
當前提交
f34f662f35
共有 4 個文件被更改,包括 4 次插入1 次删除
  1. +1
    -0
      CHANGELOG
  2. +1
    -0
      docs/changelog.rst
  3. +1
    -1
      mwparserfromhell/smart_list.py
  4. +1
    -0
      tests/test_smart_list.py

+ 1
- 0
CHANGELOG 查看文件

@@ -1,5 +1,6 @@
v0.5 (unreleased):

- Fixed len() sometimes raising ValueError on empty node lists.
- Fixed release script after changes to PyPI.

v0.4.4 (released December 30, 2016):


+ 1
- 0
docs/changelog.rst 查看文件

@@ -7,6 +7,7 @@ v0.5
Unreleased
(`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.4...develop>`__):

- Fixed ``len()`` sometimes raising ``ValueError`` on empty node lists.
- Fixed release script after changes to PyPI.

v0.4.4


+ 1
- 1
mwparserfromhell/smart_list.py 查看文件

@@ -271,7 +271,7 @@ class _ListProxy(_SliceNormalizerMixIn, list):
return bool(self._render())

def __len__(self):
return (self._stop - self._start) // self._step
return max((self._stop - self._start) // self._step, 0)

def __getitem__(self, key):
if isinstance(key, slice):


+ 1
- 0
tests/test_smart_list.py 查看文件

@@ -398,6 +398,7 @@ class TestSmartList(unittest.TestCase):
self.assertEqual([4, 3, 2, 1.9, 1.8, 5, 6], child1)
self.assertEqual([4, 3, 2, 1.9, 1.8], child2)
self.assertEqual([], child3)
self.assertEqual(0, len(child3))

del child1
self.assertEqual([1, 4, 3, 2, 1.9, 1.8, 5, 6], parent)


Loading…
取消
儲存