Commit 1ba610bf authored by Paweł Hajdan, Jr's avatar Paweł Hajdan, Jr Committed by Commit Bot

gclient validate: dump more details about unexpected AST nodes

This should make error messages more friendly and easier to address.

Bug: 570091
Change-Id: Id43d6ecdc5521b07fbe684b6fdbcc09f6fbc6448
Reviewed-on: https://chromium-review.googlesource.com/513907Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
parent 1b9a43aa
......@@ -129,8 +129,9 @@ def _gclient_eval(node_or_string, global_scope, filename='<unknown>'):
return _convert(node.left) % _convert(node.right)
else:
raise ValueError(
'unexpected AST node: %s (file %r, line %s)' % (
node, filename, getattr(node, 'lineno', '<unknown>')))
'unexpected AST node: %s %s (file %r, line %s)' % (
node, ast.dump(node), filename,
getattr(node, 'lineno', '<unknown>')))
return _convert(node_or_string)
......@@ -164,16 +165,18 @@ def _gclient_exec(node_or_string, global_scope, filename='<unknown>'):
result_scope[target.id] = value
else:
raise ValueError(
'unexpected AST node: %s (file %r, line %s)' % (
node, filename, getattr(node, 'lineno', '<unknown>')))
'unexpected AST node: %s %s (file %r, line %s)' % (
node, ast.dump(node), filename,
getattr(node, 'lineno', '<unknown>')))
if isinstance(node_or_string, ast.Module):
for stmt in node_or_string.body:
_visit_in_module(stmt)
else:
raise ValueError(
'unexpected AST node: %s (file %r, line %s)' % (
'unexpected AST node: %s %s (file %r, line %s)' % (
node_or_string,
ast.dump(node_or_string),
filename,
getattr(node_or_string, 'lineno', '<unknown>')))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment