fix(skill): force utf-8 stdout in playwright_patterns.md to prevent Windows cp1252 crash#8
Open
raykuo998 wants to merge 1 commit into
Open
Conversation
…indows cp1252 crash Both Python skeletons (Browser launch + Final-script instrumentation) now call sys.stdout.reconfigure(encoding="utf-8") at the top. The Final-script LOG file writes also pass encoding="utf-8" explicitly so non-cp1252 glyphs landing in the log cannot crash on Windows either. Added a Windows note under the Rules section explaining why the line is needed. The reconfigure is a no-op on POSIX where stdout is already utf-8, so the skeletons keep working unchanged on Linux/macOS. Fixes microsoft#7.
Author
|
@microsoft-github-policy-service agree |
4 tasks
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.
Summary
Fixes #7 — the canonical Python skeletons in
skills/webwright/reference/playwright_patterns.mdcrash withUnicodeEncodeErroron Windows the momentaria_snapshot()(or any other page text passed toprint()) contains a glyph outside cp1252.Two real-world cases that already trigger it:
U+25BDA Windows user copy-pasting the recommended explore skeleton from the doc hits the crash on the first non-trivial page. See issue #7 for the verbatim repro + traceback.
Changes
Single file:
skills/webwright/reference/playwright_patterns.md.import sysandsys.stdout.reconfigure(encoding=\"utf-8\")near the top of the heredoc with an inline comment explaining why.encoding=\"utf-8\"explicitly toLOG.write_text(...)andLOG.open(\"a\", ...)so non-cp1252 glyphs landing in the log file cannot crash on Windows either.PYTHONIOENCODING=utf-8environment override.The reconfigure is a no-op on POSIX where stdout is already utf-8, so the skeletons keep working unchanged on Linux/macOS.
Verification
Without the fix (verbatim heredoc from the doc, default Windows cp1252 stdout):
With the fix on the same arxiv search results page:
Test plan