Skip to content

Decode Child Output as UTF-8 in the Test That Fails on Windows' Code Page #2946

Closed

Description

@ptr727

The Windows unit test job logs an unhandled exception in a subprocess reader thread on every run, on develop as well as on feature branches:

File "...\Lib\subprocess.py", line 1615, in _readerthread
    buffer.append(fh.read())
File "...\Lib\encodings\cp1252.py", line 23, in decode
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1: character maps to <undefined>

Some test runs a child with text=True (or universal_newlines=True) and no encoding=, so on Windows Python decodes the child's output with the ANSI code page. A child that prints UTF-8 (byte 0x8d is a UTF-8 continuation byte) then fails to decode. The exception is raised in the reader thread, so the suite still reports OK. The child's output is lost, though, and any assertion on it reads an empty string, which can turn a check into a false green.

It appears in the log after the carry tests' output and before the next block of dots, so it is likely one of the subprocess.run(..., text=True) calls under tests/ that omits encoding="utf-8".

Fix: find the call (running the Windows leg with -v names the test) and pass encoding="utf-8", with errors="replace" where the output is only read for an assertion message.

Found while driving #2944, which does not touch the affected test.

Activity

  1. added
    gate
    pre-existing
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gatepre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions