Comment 4 for bug 1979036

Revision history for this message
Bin Li (binli) wrote :

I found a method to fix this issue, I could use 'replace' or 'ignore' errors, from the result I prefer the 'ignore'.

--- a/checkbox_support/parsers/__init__.py
+++ b/checkbox_support/parsers/__init__.py
@@ -71,7 +71,7 @@ def main():
         raise SystemExit()
     parser = AVAILABLE_PARSERS[args.parser_name]
     stdin = sys.stdin
- with io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') as stdin:
+ with io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore') as stdin:
         try:
             text = stdin.read()
             print(run_parsing(parser, text))

Using 'replace'
$ checkbox-cli run com.canonical.certification::udev_json | grep LNV
        "product": "LNV-5B10W51860\ufffd\ufffd",
        "product_slug": "LNV-5B10W51860__",
Finalizing session that hasn't been submitted anywhere: checkbox-run-2022-06-17T08.03.06

Using 'ignore'.
$ checkbox-cli run com.canonical.certification::udev_json | grep LNV
        "product": "LNV-5B10W51860",
        "product_slug": "LNV-5B10W51860",
Finalizing session that hasn't been submitted anywhere: checkbox-run-2022-06-17T08.03.32