1
0
forked from VimPlug/jedi

Add the grammar as an argument to saving the parser.

This makes collisions of different grammars when loading from the cache impossible.
This commit is contained in:
Dave Halter
2017-03-22 18:32:49 +01:00
parent c41bee4253
commit 26cce4d078
10 changed files with 41 additions and 34 deletions

View File

@@ -456,14 +456,14 @@ def _load_module(evaluator, path=None, source=None, sys_path=None, parent_module
if path is not None and path.endswith(('.py', '.zip', '.egg')) \
and dotted_path not in settings.auto_import_modules:
cached = load_parser(path)
cached = load_parser(evaluator.grammar, path)
if cached is None:
if source is None:
with open(path, 'rb') as f:
source = f.read()
p = FastParser(evaluator.grammar, source_to_unicode(source), path)
save_parser(path, p)
save_parser(evaluator.grammar, path, p)
module_node = p.get_root_node()
else:
module_node = cached.get_root_node()

View File

@@ -221,10 +221,10 @@ def _get_paths_from_buildout_script(evaluator, buildout_script):
return
p = ParserWithRecovery(evaluator.grammar, source, buildout_script)
save_parser(buildout_script, p)
save_parser(evaluator.grammar, buildout_script, p)
return p.get_root_node()
cached = load_parser(buildout_script)
cached = load_parser(evaluator.grammar, buildout_script)
module_node = cached and cached.module or load(buildout_script)
if module_node is None:
return