From e4adefd1d722b477201cd0d28c5dfcabc1f91281 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 11 Mar 2022 21:54:31 -0600 Subject: [PATCH] Fixed spurious encoding error Using errors=replace in python utf-8 decoding makes these scripts more resilient to underlying errors, rather than just throwing an unhelpfully generic decode error. --- scripts/code.py | 3 ++- scripts/data.py | 3 ++- scripts/structs.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/code.py b/scripts/code.py index 73589c1..b394e9c 100755 --- a/scripts/code.py +++ b/scripts/code.py @@ -31,7 +31,8 @@ def collect(paths, **args): proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE if not args.get('verbose') else None, - universal_newlines=True) + universal_newlines=True, + errors='replace') for line in proc.stdout: m = pattern.match(line) if m: diff --git a/scripts/data.py b/scripts/data.py index ba87fac..4b8e00d 100755 --- a/scripts/data.py +++ b/scripts/data.py @@ -31,7 +31,8 @@ def collect(paths, **args): proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE if not args.get('verbose') else None, - universal_newlines=True) + universal_newlines=True, + errors='replace') for line in proc.stdout: m = pattern.match(line) if m: diff --git a/scripts/structs.py b/scripts/structs.py index 2ec166b..e56ce9d 100755 --- a/scripts/structs.py +++ b/scripts/structs.py @@ -35,7 +35,8 @@ def collect(paths, **args): proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE if not args.get('verbose') else None, - universal_newlines=True) + universal_newlines=True, + errors='replace') for line in proc.stdout: # state machine here to find structs m = pattern.match(line)