forked from VimPlug/jedi
Error recovery should not delete parts of simple_stmt.
This commit is contained in:
@@ -460,7 +460,7 @@ class _Importer(object):
|
||||
def follow_file_system(self):
|
||||
# Handle "magic" Flask extension imports:
|
||||
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
||||
if len(self.import_path) > 2 and self.str_import_path()[:2] == ('flask', 'ext'):
|
||||
if len(self.import_path) > 2 and self.str_import_path[:2] == ('flask', 'ext'):
|
||||
orig_path = tuple(self.import_path)
|
||||
part = orig_path[2]
|
||||
pos = (part._line, part._column)
|
||||
@@ -633,7 +633,7 @@ class _Importer(object):
|
||||
if self.import_path:
|
||||
for scope in self.follow(evaluator):
|
||||
# flask
|
||||
if self.str_import_path() == ('flask', 'ext'):
|
||||
if self.str_import_path == ('flask', 'ext'):
|
||||
# List Flask extensions like ``flask_foo``
|
||||
for mod in self._get_module_names():
|
||||
modname = str(mod)
|
||||
|
||||
@@ -222,9 +222,23 @@ class Parser(object):
|
||||
elif symbol == 'suite' and len(nodes) > 1:
|
||||
# suites without an indent in them get discarded.
|
||||
break
|
||||
elif symbol == 'simple_stmt' and len(nodes) > 1:
|
||||
# simple_stmt can just be turned into a Node, if there are
|
||||
# enough statements. Ignore the rest after that.
|
||||
break
|
||||
return index, symbol, nodes
|
||||
|
||||
index, symbol, nodes = current_suite(stack)
|
||||
if symbol == 'simple_stmt':
|
||||
index -= 1
|
||||
(_, _, (typ, suite_nodes)) = stack[index]
|
||||
symbol = grammar.number2symbol[typ]
|
||||
suite_nodes.append(pt.Node(symbol, list(nodes)))
|
||||
# Remove
|
||||
nodes[:] = []
|
||||
nodes = suite_nodes
|
||||
stack[index]
|
||||
|
||||
#print('err', tokenize.tok_name[typ], repr(value), start_pos, len(stack), index)
|
||||
self._stack_removal(grammar, stack, index + 1, value, start_pos)
|
||||
if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'):
|
||||
|
||||
Reference in New Issue
Block a user