1
0
forked from VimPlug/jedi

Catch FileNotFoundError when opening file cache

This commit is contained in:
Andy Lee
2017-02-09 11:38:44 -08:00
parent d218acee6b
commit 3a851aac8c

View File

@@ -10,6 +10,7 @@ import pickle
from jedi import settings from jedi import settings
from jedi import debug from jedi import debug
from jedi._compatibility import FileNotFoundError
def underscore_memoization(func): def underscore_memoization(func):
@@ -127,12 +128,15 @@ class ParserPickling(object):
# the pickle file is outdated # the pickle file is outdated
return None return None
with open(self._get_hashed_path(path), 'rb') as f: try:
try: with open(self._get_hashed_path(path), 'rb') as f:
gc.disable() try:
parser_cache_item = pickle.load(f) gc.disable()
finally: parser_cache_item = pickle.load(f)
gc.enable() finally:
gc.enable()
except FileNotFoundError:
return None
debug.dbg('pickle loaded: %s', path) debug.dbg('pickle loaded: %s', path)
parser_cache[path] = parser_cache_item parser_cache[path] = parser_cache_item