Browse Source

!8629 print error info when the function does not meet the indentation standard of AST

From: @zhangbuxue
Reviewed-by: @zh_qh,@chenfei52
Signed-off-by: @zh_qh
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
6bdb46c705
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      mindspore/_extends/parse/parser.py

+ 8
- 1
mindspore/_extends/parse/parser.py View File

@@ -385,7 +385,14 @@ class Parser:
self.col_offset = \
len(original_src.split('\n')[0]) - len(src.split('\n')[0])
logger.debug("get source = %s", src)
tree = asttokens.ASTTokens(src, parse=True).tree
try:
tree = asttokens.ASTTokens(src, parse=True).tree
except IndentationError as idt_err:
idt_err.filename = self.filename
idt_err.lineno = self.line_offset
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] = tree
else:
logger.error("Fn type is invalid")


Loading…
Cancel
Save