QCEngine Windows Unicode Fix - #508
Open
loriab wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR hardens QCEngine’s subprocess output capture on Windows by preventing UnicodeDecodeError when decoding stdout/stderr, addressing failures triggered by non-UTF-8 bytes (e.g., Windows code pages).
Changes:
- Decode captured
stdout/stderrwitherrors="replace"to avoid crashing on invalid byte sequences. - Add inline commentary explaining the Windows/non-UTF-8 motivation for the change.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
400
to
+404
| stderr_reader.join() | ||
|
|
||
| # Retrieve the standard output for the process | ||
| ret["stdout"] = stdout.getvalue().decode() | ||
| ret["stderr"] = stderr.getvalue().decode() | ||
| # Use 'replace' error handling for robustness across platforms | ||
| # On Windows, subprocess output may contain non-UTF-8 bytes (e.g., code pages) |
loriab
marked this pull request as ready for review
June 26, 2026 23:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I started having trouble with a Psi4 test case (
tests/nbody-multi-leve/) at psi4/psi4#3389 only on Windows and having to do with the§symbol. I'm not sure about the timing but perhaps something changed in GHA Win CI? I've compensated for it in psi4 with envvarPYTHONIOENCODING=utf-8, but AI (Haiku 4.5) suggests this is the more robust sol'n.I've modified /psi/gits/QCEngine_next/qcengine/util.py to add robust error handling for subprocess output decoding on Windows.
The Fix (2-line change):
Why This is the Right Upstream Fix:
central point of failure
- Converts invalid UTF-8 sequences to U+FFFD (replacement character)
- Never crashes, just replaces bad bytes
- Is backward compatible - valid UTF-8 works exactly the same
Changelog description
Status