fix: force UTF-8 stdout in Playwright patterns to prevent UnicodeEncodeError on Windows#52
Open
C1-BA-B1-F3 wants to merge 1 commit into
Open
fix: force UTF-8 stdout in Playwright patterns to prevent UnicodeEncodeError on Windows#52C1-BA-B1-F3 wants to merge 1 commit into
C1-BA-B1-F3 wants to merge 1 commit into
Conversation
…deError on Windows On Windows, Python defaults sys.stdout.encoding to cp1252, which crashes when aria_snapshot() returns characters outside that codepage (e.g. CJK, math symbols, typography glyphs). Adding sys.stdout.reconfigure(encoding='utf-8') to the canonical code skeletons makes the patterns portable. Fixes microsoft#7
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
Forces UTF-8 stdout encoding in the canonical Playwright code skeletons to prevent
UnicodeEncodeErroron Windows.Problem
On Windows, Python defaults
sys.stdout.encodingtocp1252. Whenaria_snapshot()returns characters outside that codepage (CJK, math symbols, typography glyphs like ▽), theprint()call crashes:A Windows user copy-pasting the recommended skeleton from Webwright's own reference doc will hit this on the first non-trivial page.
Fix
Added
sys.stdout.reconfigure(encoding="utf-8")to both code skeletons:This is a no-op on POSIX where stdout is already UTF-8, so it's fully portable.
Fixes #7