Browse Source

!25609 fix col_offset not set when cache

Merge pull request !25609 from huanghui/fix-colcolum
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
bde959775c
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      mindspore/_extends/parse/parser.py

+ 7
- 4
mindspore/_extends/parse/parser.py View File

@@ -565,8 +565,8 @@ class Parser:
raise e
original_src = ''.join(lines)
hexstr = hashlib.sha256(original_src.encode()).hexdigest()
ast_tokens = Parser.ast_cache.get(hexstr)
if not ast_tokens:
ast_tokens_cache = Parser.ast_cache.get(hexstr)
if not ast_tokens_cache:
src = dedent(original_src)
self.col_offset = \
len(original_src.split('\n')[0]) - len(src.split('\n')[0])
@@ -579,8 +579,11 @@ class Parser:
idt_err.msg = f"There are incorrect indentations in definition or comment of function: " \
f"'{self.fn.__qualname__}'."
raise idt_err
Parser.ast_cache[hexstr] = ast_tokens
return ast_tokens, ast_tokens.tree
ast_tokens_cache = (ast_tokens, self.col_offset)
Parser.ast_cache[hexstr] = ast_tokens_cache
else:
self.col_offset = ast_tokens_cache[1]
return ast_tokens_cache[0], ast_tokens_cache[0].tree

logger.error("Fn type is invalid")
return None, None


Loading…
Cancel
Save