Skip to content

Read and write all text files as explicit UTF-8 #90

Closed

Description

@lanyue-llk

Problem

About 570 .read_text() calls and 220 .write_text() calls in harness/web_fetch, harness/lexbench and harness/web_search pass no encoding. Trajectory Replay has about 44 more (report_compaction.py, webarena_report_check.py, public_webarena/diagnostics.py, webarena_report.py), and Browser Use has a few (report_publish.py:241, report_package.py:66).

These calls read and write Chinese HTML and JSON with the locale encoding. They fail on Windows and under LC_ALL=C when PYTHONUTF8 is off. #84 is one instance of the same class of bug, in the risk-control compiler.

Proposal

  • Add encoding="utf-8" to every text I/O call with a mechanical codemod. Also cover open() in text mode.
  • Enforce with ruff PLW1514 (preview rule).
  • Add one regression test that runs a report build under PYTHONUTF8=0 LC_ALL=C.

Risk: low. Depends on: lint coverage stage 1. Related: #84.


Part of the refactor roadmap: #87

Activity

  1. added
    bug
    refactor
    on Oct 29, 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

    bugrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions