mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-25 06:47:12 +08:00
Fix an issue with slice indexing.
This commit is contained in:
@@ -378,7 +378,7 @@ class Evaluator(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if comp_for == ':':
|
if comp_for == ':':
|
||||||
# Dict comprehensions have it at the 3rd index.
|
# Dict comprehensions have a colon at the 3rd index.
|
||||||
try:
|
try:
|
||||||
comp_for = c[1].children[3]
|
comp_for = c[1].children[3]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|||||||
@@ -821,7 +821,11 @@ def create_index_types(evaluator, index):
|
|||||||
"""
|
"""
|
||||||
Handles slices in subscript nodes.
|
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 = []
|
result = []
|
||||||
for el in index.children:
|
for el in index.children:
|
||||||
if el == ':':
|
if el == ':':
|
||||||
@@ -835,4 +839,6 @@ def create_index_types(evaluator, index):
|
|||||||
result += [None] * (3 - len(result))
|
result += [None] * (3 - len(result))
|
||||||
|
|
||||||
return set([Slice(evaluator, *result)])
|
return set([Slice(evaluator, *result)])
|
||||||
|
|
||||||
|
# No slices
|
||||||
return evaluator.eval_element(index)
|
return evaluator.eval_element(index)
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ b[8:]
|
|||||||
#? list()
|
#? list()
|
||||||
b[int():]
|
b[int():]
|
||||||
|
|
||||||
|
#? list()
|
||||||
|
b[:]
|
||||||
|
|
||||||
|
|
||||||
class _StrangeSlice():
|
class _StrangeSlice():
|
||||||
def __getitem__(self, sliced):
|
def __getitem__(self, sliced):
|
||||||
|
|||||||
Reference in New Issue
Block a user