From ae6e9970986472994e0e40ad2eecb7308fca2ed7 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 16 Aug 2013 11:12:35 +0430 Subject: [PATCH] do some sort of error handling in fast_parser, because if fast_parser cracks down, cache might be corrupted --- jedi/fast_parser.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jedi/fast_parser.py b/jedi/fast_parser.py index 37c22d30..84ee8927 100644 --- a/jedi/fast_parser.py +++ b/jedi/fast_parser.py @@ -192,7 +192,12 @@ class FastParser(use_metaclass(CachedFastParser)): self.module = Module(self.parsers) self.reset_caches() - self._parse(code) + try: + self._parse(code) + except: + # FastParser is cached, be careful with exceptions + self.parsers[:] = [] + raise @property def user_scope(self): @@ -221,7 +226,13 @@ class FastParser(use_metaclass(CachedFastParser)): self.user_position = user_position self.reset_caches() - self._parse(code) + + try: + self._parse(code) + except: + # FastParser is cached, be careful with exceptions + self.parsers[:] = [] + raise def _scan_user_scope(self, sub_module): """ Scan with self.user_position. """