From 8193f0c2b6db16a8ead49583c1cebca8bd356852 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 26 Jan 2014 20:22:51 +0100 Subject: [PATCH] fix an issue with invalid syntax --- jedi/parser/user_context.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jedi/parser/user_context.py b/jedi/parser/user_context.py index e72f301c..fd1bb809 100644 --- a/jedi/parser/user_context.py +++ b/jedi/parser/user_context.py @@ -213,6 +213,11 @@ class UserContextParser(object): if not user_stmt: # for statements like `from x import ` (cursor not in statement) # or `abs( ` where the cursor is out in the whitespace. + if self._user_context.get_path_under_cursor(): + # We really should have a user_stmt, but the parser couldn't + # process it - probably a Syntax Error. + debug.warning('Something is probably wrong with the syntax under the cursor.') + return None pos = next(self._user_context.get_context(yield_positions=True)) user_stmt = self.module().get_statement_for_position(pos, include_imports=True) return user_stmt