tools: fix mixup with bytes.decode() and str.encode()
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 <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
f0c8898fb5
commit
6afd1a3dc1
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user