From 7a51dbea08a0e5c93acaff191deda603e4ab2e82 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 31 Mar 2017 21:03:15 +0200 Subject: [PATCH] Fix an issue in Python 2. --- jedi/parser/cache.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jedi/parser/cache.py b/jedi/parser/cache.py index ec51514e..182a8a47 100644 --- a/jedi/parser/cache.py +++ b/jedi/parser/cache.py @@ -6,6 +6,7 @@ import gc import shutil import pickle import platform +import errno from jedi import settings from jedi import debug @@ -77,9 +78,16 @@ def load_module(grammar, path): def _load_from_file_system(grammar, path, p_time): cache_path = _get_hashed_path(grammar, path) try: - if p_time > os.path.getmtime(cache_path): - # Cache is outdated - return None + try: + if p_time > os.path.getmtime(cache_path): + # Cache is outdated + return None + except OSError as e: + if e.errno == errno.ENOENT: + # In Python 2 instead of an IOError here we get an OSError. + raise FileNotFoundError + else: + raise with open(cache_path, 'rb') as f: gc.disable()