From c44ae353565fdf17ebe521189cf830a683fbc25f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 6 Jul 2022 23:12:43 +0300 Subject: [PATCH] Ignore encoding errors when scanning. Closes #10571. In Fortran and C++ all the bits we care about are in ASCII. 8-bit characters can only occur in comments and string literals and we don't parse those. --- mesonbuild/scripts/depscan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/scripts/depscan.py b/mesonbuild/scripts/depscan.py index 6f927153f..5fa30cb46 100644 --- a/mesonbuild/scripts/depscan.py +++ b/mesonbuild/scripts/depscan.py @@ -62,7 +62,7 @@ class DependencyScanner: def scan_fortran_file(self, fname: str) -> None: fpath = pathlib.Path(fname) modules_in_this_file = set() - for line in fpath.read_text(encoding='utf-8').split('\n'): + for line in fpath.read_text(encoding='utf-8', errors='ignore').split('\n'): import_match = FORTRAN_USE_RE.match(line) export_match = FORTRAN_MODULE_RE.match(line) submodule_export_match = FORTRAN_SUBMOD_RE.match(line) @@ -112,7 +112,7 @@ class DependencyScanner: def scan_cpp_file(self, fname: str) -> None: fpath = pathlib.Path(fname) - for line in fpath.read_text(encoding='utf-8').split('\n'): + for line in fpath.read_text(encoding='utf-8', errors='ignore').split('\n'): import_match = CPP_IMPORT_RE.match(line) export_match = CPP_EXPORT_RE.match(line) if import_match: