From bfcde3c5b880703e54880b71f90f8a1f6a11a1d3 Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Wed, 21 Aug 2019 22:05:03 +0000 Subject: [PATCH] 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 Commit-Queue: Edward Lesmes --- gclient_eval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gclient_eval.py b/gclient_eval.py index b87878f62..c32677ccc 100644 --- a/gclient_eval.py +++ b/gclient_eval.py @@ -688,7 +688,7 @@ def AddVar(gclient_dict, var_name, value): col = node.keys[0].col_offset # 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 # Set the ast nodes for the key and value. @@ -707,7 +707,7 @@ def AddVar(gclient_dict, var_name, value): var_tokens = { token[2]: list(token) # 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)