From 05e6471b2a23b52142048ccb92276bc04f0678a7 Mon Sep 17 00:00:00 2001 From: Polloinfilzato Date: Fri, 4 Sep 2026 12:19:13 +0200 Subject: [PATCH 1/2] test(sweep): read feedback and manifest files as UTF-8 (#624) Four bare `open(...).read()` calls used the platform default encoding and leaked the handle. The default is not UTF-8 on Windows and CI runs the suite on windows py3.11 and py3.14, so a non-ASCII byte in one of these files would raise UnicodeDecodeError there and nowhere else. Matches the sibling read at tests/test_sweep.py:4458, fixed in #616. --- tests/test_sweep.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sweep.py b/tests/test_sweep.py index cd741d8e..7f74f7d8 100644 --- a/tests/test_sweep.py +++ b/tests/test_sweep.py @@ -3932,7 +3932,7 @@ def test_sweep_happy_path(project): dev_spec = adapter.sessions[1] assert "Implement the deferred-work bundle" in dev_spec.prompt intent_path = re.findall(r"`([^`]*)`", dev_spec.prompt)[0] - intent = open(intent_path).read() + intent = Path(intent_path).read_text(encoding="utf-8") assert "fix both" in intent and "DW-2" in intent and "### DW-3" in intent @@ -5045,7 +5045,7 @@ def test_triage_validation_failure_retries_with_feedback_then_escalates(project) assert len(prompts) == 2 assert "--feedback" not in prompts[0] and "--feedback" in prompts[1] feedback_path = prompts[1].split("--feedback ", 1)[1] - assert "not triaged: DW-1" in open(feedback_path).read() + assert "not triaged: DW-1" in Path(feedback_path).read_text(encoding="utf-8") def test_triage_returning_a_nested_null_container_refuses_without_crashing_the_run(project): @@ -21553,7 +21553,7 @@ def test_migration_validation_failure_restores_ledger_then_escalates(project): prompts = [s.prompt for s in adapter.sessions] assert len(prompts) == 2 assert "--feedback" not in prompts[0] and "--feedback" in prompts[1] - feedback = open(prompts[1].split("--feedback ", 1)[1]).read() + feedback = Path(prompts[1].split("--feedback ", 1)[1]).read_text(encoding="utf-8") assert "still parse as legacy" in feedback and "not mapped" in feedback From 7be678cf868625c37ac5a68b774fc0065c98103e Mon Sep 17 00:00:00 2001 From: t Date: Tue, 29 Sep 2026 14:54:34 -0700 Subject: [PATCH 2/2] test(sweep): read the three newer feedback files as UTF-8 (#624) Three bare open().read() calls added after #766 was opened (triage nested-null, triage non-mapping, migration non-mapping). The manifest read the PR originally converted was already fixed on main by 14d9c0c8 (DW-288) and is dropped from the rebased commit. --- tests/test_sweep.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_sweep.py b/tests/test_sweep.py index 7f74f7d8..2fd96e2e 100644 --- a/tests/test_sweep.py +++ b/tests/test_sweep.py @@ -5081,7 +5081,7 @@ def test_triage_returning_a_nested_null_container_refuses_without_crashing_the_r assert len(prompts) == 2 assert "--feedback" not in prompts[0] and "--feedback" in prompts[1] feedback_path = prompts[1].split("--feedback ", 1)[1] - assert "bundles[0] not an object: NoneType" in open(feedback_path).read() + assert "bundles[0] not an object: NoneType" in Path(feedback_path).read_text(encoding="utf-8") def test_triage_returning_a_non_mapping_document_refuses_without_crashing_the_run(project): @@ -5130,7 +5130,9 @@ def test_triage_returning_a_non_mapping_document_refuses_without_crashing_the_ru assert len(prompts) == 2 assert "--feedback" not in prompts[0] and "--feedback" in prompts[1] feedback_path = prompts[1].split("--feedback ", 1)[1] - assert "triage result not a JSON object: list" in open(feedback_path).read() + assert "triage result not a JSON object: list" in Path(feedback_path).read_text( + encoding="utf-8" + ) # nothing escaped `run()`: no crash record, and a refused triage classified # nothing, so the ledger it was reading is left exactly as it was assert _records(engine, "run-crash") == [] @@ -23027,7 +23029,9 @@ def non_mapping_migrate(spec): assert len(prompts) == 2 assert "--feedback" not in prompts[0] and "--feedback" in prompts[1] feedback_path = prompts[1].split("--feedback ", 1)[1] - assert "migration result not a JSON object: list" in open(feedback_path).read() + assert "migration result not a JSON object: list" in Path(feedback_path).read_text( + encoding="utf-8" + ) # nothing escaped `run()`, and the un-migrated ledger is left as it was assert _records(engine, "run-crash") == [] assert project.deferred_work.read_text(encoding="utf-8") == LEGACY_LEDGER