From 6afd1a3dc183eb0edfde878df7a655cc58caece4 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 19 Aug 2019 19:24:22 +0200 Subject: tools: fix mixup with bytes.decode() and str.encode() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to read a bytes file and decode the contents as utf-8 so we can compare against a utf-8 pattern. PR-URL: https://github.com/nodejs/node/pull/29208 Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso --- tools/v8_gypfiles/GN-scraper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/v8_gypfiles/GN-scraper.py b/tools/v8_gypfiles/GN-scraper.py index 59818ad737..ec72f1d47e 100644 --- a/tools/v8_gypfiles/GN-scraper.py +++ b/tools/v8_gypfiles/GN-scraper.py @@ -7,8 +7,8 @@ PLAIN_SOURCE_RE = re.compile('\s*"([^/$].+)"\s*') def DoMain(args): gn_filename, pattern = args src_root = os.path.dirname(gn_filename) - with open(gn_filename, 'r') as gn_file: - gn_content = gn_file.read().encode('utf-8') + with open(gn_filename, 'rb') as gn_file: + gn_content = gn_file.read().decode('utf-8') scraper_re = re.compile(pattern + r'\[([^\]]+)', re.DOTALL) matches = scraper_re.search(gn_content) -- cgit v1.2.3