Fixed #29432 -- Allowed passing an integer to the slice template filter.

This commit is contained in:
ryabtsev 2018-05-27 02:56:51 +02:00 committed by Tim Graham
parent 39283c8edb
commit b4fd9b5ad4
2 changed files with 4 additions and 1 deletions

View File

@ -573,7 +573,7 @@ def slice_filter(value, arg):
"""
try:
bits = []
for x in arg.split(':'):
for x in str(arg).split(':'):
if not x:
bits.append(None)
else:

View File

@ -26,6 +26,9 @@ class FunctionTests(SimpleTestCase):
def test_index(self):
self.assertEqual(slice_filter('abcdefg', '1'), 'a')
def test_index_integer(self):
self.assertEqual(slice_filter('abcdefg', 1), 'a')
def test_negative_index(self):
self.assertEqual(slice_filter('abcdefg', '-1'), 'abcdef')