Browse Source

Fix bug of getting name of a function

tags/v1.1.0
fary86 5 years ago
parent
commit
3f5640f18a
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      mindspore/_extends/parse/parser.py

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

@@ -339,7 +339,9 @@ def get_object_description(obj, fname, fline):
_, cls_fline = inspect.getsourcelines(obj_cls)
class_loc = f'{cls_fname}:{cls_fline}'
return f"bound method '{obj.__name__}' at {fname}:{fline} of <{class_name} at {class_loc} object>"
if isinstance(obj, (types.FunctionType, ast.FunctionDef)):
if isinstance(obj, types.FunctionType):
return f"function '{obj.__name__}' at {fname}:{fline}"
if isinstance(obj, ast.FunctionDef):
return f"function '{obj.name}' at {fname}:{fline}"
return str(obj)



Loading…
Cancel
Save