瀏覽代碼

Fix for python2.7

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
MegaIng1 4 年之前
父節點
當前提交
c9b5443127
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. +5
    -5
      lark/load_grammar.py

+ 5
- 5
lark/load_grammar.py 查看文件

@@ -663,17 +663,17 @@ def import_grammar(grammar_path, re_, base_paths=(), import_sources=()):
if grammar_path not in _imported_grammars:
import_paths = import_sources + base_paths + [stdlib_loader]
for source in import_paths:
if isinstance(source, str):
if callable(source):
with suppress(IOError):
joined_path = os.path.join(source, grammar_path)
with open(joined_path, encoding='utf8') as f:
text = f.read()
joined_path, text = source(base_paths, grammar_path)
grammar = load_grammar(text, joined_path, re_, import_sources)
_imported_grammars[grammar_path] = grammar
break
else:
with suppress(IOError):
joined_path, text = source(base_paths, grammar_path)
joined_path = os.path.join(source, grammar_path)
with open(joined_path, encoding='utf8') as f:
text = f.read()
grammar = load_grammar(text, joined_path, re_, import_sources)
_imported_grammars[grammar_path] = grammar
break


Loading…
取消
儲存