Skip to content

Commit

Permalink
Replace comments with blank lines so that error messages are not misp…
Browse files Browse the repository at this point in the history
…laced (#39035)
  • Loading branch information
0x45f authored Jan 24, 2022
1 parent 9cfa811 commit 95b081e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/paddle/fluid/dygraph/dygraph_to_static/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,10 @@ def func_to_source_code(function, dedent=True):
"The type of 'function' should be a function or method, but received {}.".
format(type(function).__name__))
source_code_list, _ = inspect.getsourcelines(function)
# Replace comments with blank lines so that error messages are not misplaced
source_code_list = [
line for line in source_code_list if not line.lstrip().startswith('#')
line if not line.lstrip().startswith('#') else '\n'
for line in source_code_list
]
source_code = ''.join(source_code_list)
if dedent:
Expand Down

0 comments on commit 95b081e

Please sign in to comment.