mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
gclient_eval: Make compatible with Python 3.
A new-line token is being added on Python 3, so add it explicitly so that it also appears on Python 2. Bug: 984182 Change-Id: I3bfb6ca83d94b6a3452b938f35f5a3174fe85903 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1764465 Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
@@ -688,7 +688,7 @@ def AddVar(gclient_dict, var_name, value):
|
|||||||
col = node.keys[0].col_offset
|
col = node.keys[0].col_offset
|
||||||
|
|
||||||
# We use a minimal Python dictionary, so that ast can parse it.
|
# We use a minimal Python dictionary, so that ast can parse it.
|
||||||
var_content = '{\n%s"%s": "%s",\n}' % (' ' * col, var_name, value)
|
var_content = '{\n%s"%s": "%s",\n}\n' % (' ' * col, var_name, value)
|
||||||
var_ast = ast.parse(var_content).body[0].value
|
var_ast = ast.parse(var_content).body[0].value
|
||||||
|
|
||||||
# Set the ast nodes for the key and value.
|
# Set the ast nodes for the key and value.
|
||||||
@@ -707,7 +707,7 @@ def AddVar(gclient_dict, var_name, value):
|
|||||||
var_tokens = {
|
var_tokens = {
|
||||||
token[2]: list(token)
|
token[2]: list(token)
|
||||||
# Ignore the tokens corresponding to braces and new lines.
|
# Ignore the tokens corresponding to braces and new lines.
|
||||||
for token in var_tokens[2:-2]
|
for token in var_tokens[2:-3]
|
||||||
}
|
}
|
||||||
|
|
||||||
gclient_dict.tokens = _ShiftLinesInTokens(gclient_dict.tokens, 1, line)
|
gclient_dict.tokens = _ShiftLinesInTokens(gclient_dict.tokens, 1, line)
|
||||||
|
|||||||
Reference in New Issue
Block a user