From 89bd55b9da6675d17bd4431aed99354603a7b312 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 20 Apr 2020 17:33:58 +0800 Subject: [PATCH] gtkdochelper.py: Ignore UnicodeEncodeError when printing output Windows cmd.exe consoles may be using a code page that might choke print() when we are outputting the output from calling gtk-doc. Let's just ignore the error when it happens and print as much as we could in this situation. --- mesonbuild/scripts/gtkdochelper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index 36660effa..6b174a6c4 100644 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -74,7 +74,14 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None): err_msg.append(out) raise MesonException('\n'.join(err_msg)) elif out: - print(out) + # Unfortunately Windows cmd.exe consoles may be using a codepage + # that might choke print() with a UnicodeEncodeError, so let's + # ignore such errors for now, as a compromise as we are outputting + # console output here... + try: + print(out) + except UnicodeEncodeError: + pass def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, main_file, module, module_version,