@@ -1,5 +1,6 @@ | |||||
v0.5 (unreleased): | v0.5 (unreleased): | ||||
- Fixed len() sometimes raising ValueError on empty node lists. | |||||
- Fixed release script after changes to PyPI. | - Fixed release script after changes to PyPI. | ||||
v0.4.4 (released December 30, 2016): | v0.4.4 (released December 30, 2016): | ||||
@@ -7,6 +7,7 @@ v0.5 | |||||
Unreleased | Unreleased | ||||
(`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.4...develop>`__): | (`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. | - Fixed release script after changes to PyPI. | ||||
v0.4.4 | v0.4.4 | ||||
@@ -271,7 +271,7 @@ class _ListProxy(_SliceNormalizerMixIn, list): | |||||
return bool(self._render()) | return bool(self._render()) | ||||
def __len__(self): | def __len__(self): | ||||
return (self._stop - self._start) // self._step | |||||
return max((self._stop - self._start) // self._step, 0) | |||||
def __getitem__(self, key): | def __getitem__(self, key): | ||||
if isinstance(key, slice): | if isinstance(key, slice): | ||||
@@ -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, 5, 6], child1) | ||||
self.assertEqual([4, 3, 2, 1.9, 1.8], child2) | self.assertEqual([4, 3, 2, 1.9, 1.8], child2) | ||||
self.assertEqual([], child3) | self.assertEqual([], child3) | ||||
self.assertEqual(0, len(child3)) | |||||
del child1 | del child1 | ||||
self.assertEqual([1, 4, 3, 2, 1.9, 1.8, 5, 6], parent) | self.assertEqual([1, 4, 3, 2, 1.9, 1.8, 5, 6], parent) | ||||