Skip to content

Commit 1e8484b

Browse files
rokmbwoodsend
authored andcommitted
hookutils: gi: fix error handling in compile_glib_schema_files
Fix error handling in compile_glib_schema_files; do not attempt to access attributes of `p`, which is unavailable in the exception handling block. To display stdout/stderr of the failed process, use attributes of the `subprocess.CalledProcessError` instead. Ignore the character encoding errors when decoding stdout/stderr from the `glib-compile-schema` process. The warnings it emits seem to use `U+201C` and `U+201D` quotation marks, which might cause issues with active locale (for example, in msys2/mingw64 environment).
1 parent e7f6380 commit 1e8484b

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎PyInstaller/utils/hooks/gi.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,17 @@ def compile_glib_schema_files(datas_toc, workdir, collect_source_files=False):
395395
stderr=subprocess.STDOUT,
396396
check=True,
397397
text=True,
398+
errors='ignore',
398399
)
399-
logger.debug("Extra output from glib-compile-schemas:\n%s", p.stdout)
400+
logger.debug("Output from glib-compile-schemas:\n%s", p.stdout)
401+
except subprocess.CalledProcessError as e:
402+
# The called glib-compile-schema returned error. Display stdout/stderr, and return original datas TOC to
403+
# minimize damage.
404+
logger.warning("Failed to recompile GLib schemas! Returning collected files as-is!", exc_info=True)
405+
logger.warning("Output from glib-compile-schemas:\n%s", e.stdout)
406+
return datas_toc
400407
except Exception:
401408
# Compilation failed for whatever reason. Return original datas TOC to minimize damage.
402-
logger.warning("Extra output from glib-compile-schemas:\n%s", p.stdout)
403409
logger.warning("Failed to recompile GLib schemas! Returning collected files as-is!", exc_info=True)
404410
return datas_toc
405411

‎news/7833.bugfix.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix error handling in GLib schema compilation helper function. Ignore
2+
character encoding errors when reading stdout/stderr from ``glib-schema-compile``
3+
process; this fixes errors in msys2/mingw64 environment, caused by
4+
``U+201C`` and ``U+201D`` quotation marks in the output.

0 commit comments

Comments
 (0)