Skip to content

Avoid UnicodeDecodeError from command output #2970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test_sync_write_decode_surrogate: utf-8 decode
When SyncWrite decodes bytes as utf-8, it should replace unknown
sequences with the unicode surrogate codepoint instead of crashing the
program.

Test case for #2969
  • Loading branch information
masenf committed Apr 3, 2023
commit 7113234c1404985dd20dc6601575a119cb0b0e13
6 changes: 6 additions & 0 deletions tests/execute/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
def test_sync_write_repr() -> None:
sync_write = SyncWrite(name="a", target=None, color=Fore.RED)
assert repr(sync_write) == f"SyncWrite(name='a', target=None, color={Fore.RED!r})"


def test_sync_write_decode_surrogate() -> None:
sync_write = SyncWrite(name="a", target=None)
sync_write.handler(b"\xed\n")
assert sync_write.text == "\udced\n"