1
0
forked from VimPlug/jedi

Fix an issue with slice indexing.

This commit is contained in:
Dave Halter
2016-07-14 18:27:15 +02:00
parent 3a0008ea80
commit 218278af8d
3 changed files with 11 additions and 2 deletions

View File

@@ -378,7 +378,7 @@ class Evaluator(object):
pass
else:
if comp_for == ':':
# Dict comprehensions have it at the 3rd index.
# Dict comprehensions have a colon at the 3rd index.
try:
comp_for = c[1].children[3]
except IndexError:

View File

@@ -821,7 +821,11 @@ def create_index_types(evaluator, index):
"""
Handles slices in subscript nodes.
"""
if tree.is_node(index, 'subscript'): # subscript is a slice operation.
if index == ':':
# Like array[:]
return set([Slice(evaluator, None, None, None)])
elif tree.is_node(index, 'subscript'): # subscript is a slice operation.
# Like array[:3]
result = []
for el in index.children:
if el == ':':
@@ -835,4 +839,6 @@ def create_index_types(evaluator, index):
result += [None] * (3 - len(result))
return set([Slice(evaluator, *result)])
# No slices
return evaluator.eval_element(index)

View File

@@ -39,6 +39,9 @@ b[8:]
#? list()
b[int():]
#? list()
b[:]
class _StrangeSlice():
def __getitem__(self, sliced):