Bläddra i källkod

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

tags/v0.5
Ben Kurtovic 7 år sedan
förälder
incheckning
f34f662f35
4 ändrade filer med 4 tillägg och 1 borttagningar
  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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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)


Laddar…
Avbryt
Spara