Skip to content

tests/conftest.py: under a one-byte locale skip_where_a_name_cannot_be_not_utf_8 says it also skips the branch rows, its first two questions are one predicate, and rows hold the order it asks them in, on Windows too (#1224) - #1326

Draft
brettheap wants to merge 2 commits into
fix/1196-paths-spelled-locale-and-envfrom
fix/1224-locale-question-own-helper

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1224

This PR lands after #1209. It is stacked on #1209's branch (fix/1196-paths-spelled-locale-and-env, head 01ee6976), and is restacked onto main once #1209 has landed.

One commit on 01ee69763, four test files, no tool changed: tests/conftest.py, tests/test_non_utf8_name_callers.py, tests/test_non_utf8_name_helpers.py, tests/test_adopt_plan_paths_spelled.py. Writer W1224, lane openRepoShape-4. All figures below were measured on 2026-11-10, after #1258 and RS1209's restack; none of RV1209's Latin-1 counts is used as a baseline.

What

Measured, base against head, by locale

Base 01ee69763 (#1209's head) against this head e73592062, compared by test id, in the landing-gate environment: a stub gh, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, an empty global git config, GIT_CONFIG_NOSYSTEM=1, git filter-repo on PATH, and /usr/bin/python3 -m pytest -p no:cacheprovider, at most two runs at a time.

N1's decision and its evidence

The brief's rule: take the first choice (the locale question in a helper of its own, asked only by the rows whose premise is that Python reads 0xFF in as U+DCFF) unless more than 12 rows then need a new premise skip under Latin-1.

The first choice was built and measured first, as commit f48f46c7f on 01ee69763 (kept locally as refs/w1224/first-choice, not pushed). It had a new skip_where_the_locale_reads_the_byte_as_text(), asked by the --work-dir row and the two --out rows of tests/test_stdout_encoding.py, and the locale halves of both guards dropped. Under Latin-1, the 31 files, base 01ee69763 against f48f46c7f, by test id:

The ids are in the lane's scratch folder (tools/run/w1224/): base-latin1.ids, head-latin1.ids (the first choice), delta-latin1.txt, s2f-msgs.txt.

Rows

Row NIT At the base 01ee69763 At this head
test_an_earlier_question_skips_where_the_helper_skips_before_the_disk[utf-8], [ascii], [latin-1], [windows] (helpers file, new) N4 absent (no predicate) 4 passed, under UTF-8, Latin-1 and Windows' os.fsencode
test_the_child_read_as_bytes_is_started_as_run_script_starts_one (spelled file, new) N5 absent passed, UTF-8, Latin-1 and ASCII
test_a_locale_that_reads_the_byte_as_a_character_skips_before_the_disk (helpers file, changed) N2 passes on Linux; fails with Windows' os.fsencode emulated for the run ("this system's os.fsencode makes no byte...", no 0xFF), as RV1209 found passes on Linux and with Windows' os.fsencode emulated
test_where_fsencode_makes_three_bytes_the_disk_is_not_asked (helpers file, changed) N3 passes with RV1209's G4 put in: G4 survives (42 passed) G4 fails it (UnicodeDecodeError)

Windows' os.fsencode "emulated for the run" means a pytest plugin that replaces os.fsencode with UTF-8 surrogatepass before each test's fixtures and puts it back after its teardown, as RV1209 emulated it. It lives in the lane's scratch folder (tools/run/w1224/plugins/), not in the PR. The new rows are in ASCII source, with escapes.

Counts for the changed files, base against head:

  • helpers file: UTF-8 42 passed against 46 passed; Latin-1 37 passed and 5 skipped against 41 passed and 5 skipped. The same 5 skip.
  • spelled file: one row more, passing in every locale (ASCII below).
  • callers file: the same rows and outcomes.

Mutants

Run one at a time in a worktree at this head, each file put back with git checkout after each and its sha256 checked against HEAD's (all 12 matched). Each kills at least one row:

Mutant Locale Rows failed
N1: the shared helper asks no locale (the first choice's helper) UTF-8 2: the N2 row and [latin-1] of the predicate row
N3: the shared helper asks the locale before the system (RV1209's G4) UTF-8 2: ..._the_disk_is_not_asked and [windows] (UnicodeDecodeError)
N4-a: the predicate without its locale half UTF-8 1: [latin-1]
N4-b: the predicate without its system half UTF-8 1: [windows] (UnicodeDecodeError)
N4-c: the predicate asks the locale first UTF-8 1: [windows]
N4-d: a third question in the helper before the disk (it skips an ASCII locale) that the predicate lacks UTF-8 1: [ascii]
N4-e: the callers fixture asks only the system (RV1209's F1) Latin-1 13 callers rows, each on the helper's locale reason
N4-f: the helpers guard asks only the system (RV1209's F2) Latin-1 5
N2: the Latin-1 row patches os.fsdecode alone, as at the base Windows' os.fsencode emulated 1: the N2 row
N5-a: the bytes child gets AGENT_PROTOCOL_ROOT, as child_environ gives it UTF-8 1: the N5 row
N5-b: the bytes child keeps this process's LANES_LANE UTF-8 1
N5-c: the bytes child gets no git identity UTF-8 1

The first choice's own 15 mutants were also all killed at f48f46c7f. They are moot here, and their log is in the scratch folder (logs/mutants.txt).

Gate

The list is tools/run/w1224/gate1224.txt in the lane's scratch folder, 38 files:

  • the 31 files above, which are every test file that reaches skip_where_a_name_cannot_be_not_utf_8 or a_system_that_carries_the_byte (RS1209's fixpoint) plus tests/test_repo_hygiene.py;
  • the 7 other files that name a module, helper or row changed here: they import tests/test_stdout_encoding.py (test_bootstrap_non_utf8_branch.py, test_bootstrap_spelling.py, test_chain_link_fold.py, test_pinned_copy_columns.py, test_siblings_family_name.py, test_validator_child_encoding.py), or the callers file imports them (test_non_utf8_git_reads.py).

Results:

  • UTF-8, the 38 files: 2466 rows, 2459 passed, 7 skipped, 0 failed (the 31 files as above; the 7 others 680 passed).
  • Latin-1, the 31 files: as above.
  • ASCII, the spelled file: as above.
  • tests/test_repo_hygiene.py: 101 passed, under UTF-8 and Latin-1.

Merge-trees

git merge-tree --write-tree of this head, at 2026-11-10T21:18Z:

Not in this PR (follow-up candidates for Brett Heap; none filed)

Fix round (FX1224)

RV1224 graded e73592062 NOT READY for one SHOULD and three NITs (#1326 issuecomment-6783237077). Everything above describes e73592062; this section is the delta on top of it. The head is now 3f668f4f2, one commit on e73592062, in three files: tests/conftest.py, tests/test_non_utf8_name_helpers.py, tests/test_non_utf8_name_callers.py. No tool changed, and scripts/family.py is not touched (its defect stays a follow-up candidate, above). The new source is ASCII, with escapes.

New rows: 9 (helpers 7, callers 2), each passing under UTF-8 and under Latin-1. Base e73592062 against this head, by test id, the helpers, callers and spelled files and tests/test_repo_hygiene.py:

  • UTF-8: 215 passed against 224 passed. Latin-1: 178 passed and 37 skipped against 187 passed and 37 skipped. No row changes outcome, and none goes from passed to failed; the 9 new rows are the only change.
  • ASCII, the spelled file: 17 passed and 15 skipped at both. Hygiene: 101 passed at both, UTF-8 and Latin-1.

Mutants, run one at a time in a worktree at this head under UTF-8, each file put back with git checkout and its sha256 checked against HEAD's. At e73592062 each survived under UTF-8, as RV1224 found:

Mutant Rows failed at this head
M2: windows_fsdecode decodes with surrogateescape 1: test_windows_fsdecode_raises_on_a_byte_that_is_not_utf_8
M2 with RV1209's G4 (the locale asked before the system) 1: the same row
M7: skip_where_an_earlier_question_skips inverted 3: the three guard rows
M7b: a_system_that_carries_the_byte inverted 2: the two fixture rows
M14: the predicate's locale half narrowed to U+00FF 1: [cp1251]

SonarCloud at 3f668f4f2: quality gate passed, 0 open issues, 0.0% duplication. git merge-tree --write-tree of this head is clean against origin/main a6f1374b0, #1209's head, #1312 and #1302.

Lane 4 logs OPENED for #1224; an independent review comes next.

🤖 Generated with Claude Code
Lane: openreposhape-4 (openRepoShape-4)

Summary by Sourcery

Align non-UTF-8 filename test skips with platform and locale behavior while consolidating shared predicates and strengthening cross-platform coverage.

Bug Fixes:

  • Correct test skip behavior for one-byte locales and Windows by keeping system and locale checks in the intended order and aligning dependent guards with that ordering.

Enhancements:

  • Centralize the predicate identifying skips that occur before disk access and share the Windows filesystem-decoding emulation across tests.
  • Clarify skip reasons and documentation for branch and filename cases affected by locale decoding.
  • Verify child-process environments against the environment used by the normal script runner.

Tests:

  • Add coverage for skip-predicate behavior across UTF-8, ASCII, Latin-1, CP1251, and Windows filesystem semantics.
  • Add tests for Windows filesystem decoding behavior and for the child environment passed to subprocesses.

Chores:

  • Remove the duplicate filesystem-decoding helper and resolve the resulting static-analysis warning.

…under a one-byte locale it also skips the rows about a branch or a file named with the byte 0xFF, its first two questions are one predicate both guards ask, the system is held to be asked before the locale with Windows' `os.fsdecode`, the Latin-1 row holds on Windows, and the bytes child of the spelled file is said to start as `run_script` starts one, which a row holds (#1224)

N1, the second choice. The locale question stays in the shared helper.
Moved into a helper of its own, asked only by the rows whose premise is
that Python reads the byte 0xFF in as U+DCFF, it left 67 rows of the 31
gate files going from skipped to failed under Latin-1, 63 of them on
their own UTF-8 premise, over the brief's 12. The docstring now says that
under a one-byte locale it also skips the branch rows, and why it is kept;
its skip no longer says that no file name here is one that is not UTF-8.

N4: `an_earlier_question_skips()`, beside the helper, is its first two
questions; the callers fixture `a_system_that_carries_the_byte` and the
helpers file's `skip_where_an_earlier_question_skips` each ask it and
keep their own skip. Four rows hold it to the helper under UTF-8, ASCII,
Latin-1 and Windows, each emulated.

N2: the Latin-1 row emulates POSIX's `os.fsencode` with Latin-1's
`os.fsdecode` (`locale_of`), so the system's question lets it through on
Windows too.

N3: `test_where_fsencode_makes_three_bytes_the_disk_is_not_asked` also
emulates Windows' `os.fsdecode`, which raises on the byte 0xFF, so the
locale asked before the system fails it. `windows_fsdecode` moves from
the callers file into `tests/conftest.py`, beside `windows_fsencode`.

N5: `the_environment_of_a_child_read_as_bytes` says its child starts as
`run_script` starts every other child, and a row compares the two
environments key for key.

The helpers file's first `fsdecode_in`, which its later definition
rebound (pyflakes: redefinition of unused 'fsdecode_in'), is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap brettheap added this to the v1.2.1 milestone Nov 10, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Clarify the shared non-UTF-8 name skip’s locale behavior and centralize its first two ordered checks, then verify the predicate agrees with the helper across UTF-8, ASCII, Latin-1, cp1251, and Windows.

  • tests/conftest.py L1170-1176, L1183-1193, L1213-1226 (+1 small edits)
  • tests/test_non_utf8_name_callers.py L54-59, L134-137, L199-221
  • tests/test_non_utf8_name_helpers.py L22-27, L49-53, L285-356 (+1 small edits)

Move the Windows filesystem-decoding emulation into shared test support and exercise its behavior, including that the system check runs before a locale check that would raise on Windows.

  • tests/conftest.py L1298-1310, L1373-1375
  • tests/test_non_utf8_name_helpers.py L129-156, L213-218 (+3 small edits)

Make the Latin-1 skip test emulate POSIX filesystem encoding as well as locale decoding, so it also tests the intended behavior under emulated Windows encoding.

  • tests/test_non_utf8_name_helpers.py L245-250, L257

Align the byte-oriented child environment’s description with run_script and add a comparison that checks the environments under overridden lane, pin-source, and git-identity settings.

  • tests/test_adopt_plan_paths_spelled.py L311-313, L363-395

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

RV1224: independent review of #1326 at e7359206: NOT READY

One SHOULD, a sentence in tests/conftest.py; three NITs (A to C, named so as not to be read as #1224's N1 to N5). Otherwise the PR holds: N1's second choice is the right change here, N2 to N5 meet #1224's "Done when", every count in the body that I ran again reproduced, and SonarCloud's quality gate passed. A real tool defect sits behind the 4 utf8-keeps-shlex-quote rows: it is outside this PR, and it already fails those rows under ASCII.

Reviewed head e735920624150449600d896b8ca29c07415f9455 (unchanged since the writer's report), base 01ee69763 (#1209's head). Environment: the landing gate's (a stub gh first on PATH, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, an empty global git config, GIT_CONFIG_NOSYSTEM=1, git filter-repo on PATH, /usr/bin/python3 -m pytest -p no:cacheprovider, at most two runs at a time). Compared by test id from junit files. Latin-1 is lane 4's LOCPATH=.../rv1258/locales LC_ALL=en_US.ISO-8859-1 PYTHONUTF8=0, where Python reports iso8859-1 and reads 0xFF as '\xff'.

Counts, base against head, by id

Run Base 01ee69763 Head e7359206 By id
31 files of the #1209 kit, UTF-8 1781 rows: 1774 passed, 7 skipped 1786 rows: 1779 passed, 7 skipped every row keeps its outcome; the only change is the 5 new rows, absent before and passing now (helpers 42 to 46 passed)
the 31 files, Latin-1 1781 rows: 1359 passed, 123 failed, 299 skipped 1786 rows: 1364 passed, 123 failed, 299 skipped the same 123 fail; 0 rows from passed to failed; the only change is the 5 new rows, absent before and passing now
test_adopt_plan_paths_spelled.py, ASCII (LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0) 16 passed, 15 skipped 17 passed, 15 skipped the N5 row
test_repo_hygiene.py (in the 31) 101 passed, UTF-8 and Latin-1 101 passed, UTF-8 and Latin-1 no change
helpers file with Windows' os.fsencode emulated for every row (my own plugin, not the writer's) 42 rows: 32 passed, 5 failed, 5 skipped 46 rows: 37 passed, 4 failed, 5 skipped the N2 row goes from failed to passed; the 4 new N4 rows pass; the 4 failing at both are LINUX_ONLY rows, which the emulation runs on Linux

Per file at the head: helpers 46 passed (UTF-8), 41 passed and 5 skipped (Latin-1); callers 36 passed (UTF-8), 18 passed and 18 skipped (Latin-1), the same ids as the base; spelled 32 passed (UTF-8), 18 passed and 14 skipped (Latin-1).

N1: the first choice, measured again

I fetched the writer's unpushed f48f46c7f read-only and read its diff. It is the issue's first choice: skip_where_the_locale_reads_the_byte_as_text() on the 0xff --work-dir row and on both --out rows ([utf-8:surrogateescape], [cp1252:surrogateescape]), and the locale halves of both guards dropped. Under Latin-1, the 31 files, against 01ee69763: 1786 rows, 1465 passed, 190 failed, 131 skipped. By id, 101 rows go from skipped to passed and 67 from skipped to failed, the writer's counts (the writer also saw one row go from passed to skipped; I saw none). Each of the 67 skipped at the base on the shared helper's locale reason. The three rows that keep the locale question still skip.

The 67, by file: 33 test_adopt_plan_and_remote_paths_spelled.py, 12 test_clone_url_bytes.py, 10 test_local_remote_dir_urls.py, 4 test_family_leg_path_by_hand_bytes.py, 2 test_family_member_branch_not_utf8.py, and 1 each in test_adopt_git_reads.py, test_adopt_pins.py, test_adopt_plan_escapes.py, test_adopt_template_values.py, test_bootstrap_branch_bytes.py and test_bootstrap_leg_moves.py.

I read 19 of them in full: 15 that stand for the premise classes, plus the 4 defect rows. The first failure line of each of the other 48 falls in the same classes.

  • The test fails itself, 29 rows. Read: test_the_plan_is_named_as_a_path_is[mistyped-plan-check-byte-0xff-not-utf-8]. It is UnicodeEncodeError for U+2014 at the test's own path.write_bytes(os.fsencode(...)) (line 426). All 116 such failures in the run raise there: these 29, and the 87 that fail at both base and head.
  • The tool prints 0xFF as the text U+00FF, where the row expects \udcff spelled:
    • [plan-unreadable-check-byte-0xff-not-utf-8] (pl U+00FF an.yaml);
    • test_a_remote_dir_is_named_in_the_bare_and_leg_lines_as_a_path_is[byte-0xff-not-utf-8] and test_a_refused_command_names_the_remote_and_work_dirs_spelled[byte-0xff-not-utf-8] (re U+00FF mote);
    • test_bootstrap_branch_bytes.py's row 4 and test_bootstrap_leg_moves.py's row: bootstrap says ok, but the branch prints as a U+00FF b, where the row expects a\udcffb.
  • caf 0xE9 is the text caf U+00E9 in Latin-1, so the tool goes on where the row expects the refusal of a name that is not UTF-8. Read:
    • test_a_scaffold_into_a_directory_no_file_can_name_is_refused[not-utf8-real] and test_the_scaffold_as_a_person_runs_it_creates_nothing_and_raises_nothing[real];
    • test_add_from_a_directory_no_file_can_name_is_refused[not-utf8-real] and test_add_follows_its_own_remedy_to_a_mount[directory-renamed];
    • the single rows of test_adopt_git_reads.py, test_adopt_template_values.py, test_adopt_pins.py and test_adopt_plan_escapes.py: execute adopts, plan goes on, or _spelled prints the text.
    • I checked the scaffold row's kept basetemp. Its .gitmodules URLs hold the disk's byte 0xE9, and both legs are checked out on main, so the tool is right there.
  • Output escaped by the locale: test_family_member_branch_not_utf8.py[bump]. The rollback is right, but a Latin-1 stderr writes U+FFFD as \ufffd (adopt-project.py plan raises UnicodeEncodeError in its terminal report, after the plan file is written, for a printable name stdout cannot encode (日本.md under cp1252, as on a redirected Windows stdout), so plan exits 1 before plan written to #214).
  • A tool defect: the 4 test_family_leg_path_by_hand_bytes.py [utf8-keeps-shlex-quote-*] rows (below).

So 63 rows fail on their own UTF-8 premise, as the writer found, and 4 fail on a tool defect. N1's decision stands. The first choice needs 63 premise skips in 10 test files outside this PR, against the brief's limit of 12, and it would leave 4 rows failing until the defect is mended. The second choice is what #1224's "Done when" offers ("or the docstring says they skip there"). There is no MUST or SHOULD in the choice itself. Two things favour the first choice later, as a follow-up: it is what surfaced the defect below, and it lets 101 rows in 21 files judge under Latin-1.

Findings

S1 (SHOULD): tests/conftest.py still says a branch row judges under a one-byte locale, citing this NIT

Where. skip_where_the_locale_does_not_spell_it_as_utf_8's docstring, tests/conftest.py:1371-1373 at this head (written by #1258), says: "A branch whose bytes are not UTF-8 (on_a_branch_that_is_not_utf_8) is one in every locale, and a row about it judges there too (#1224's N1)."

Why it is wrong. This PR's new paragraph at :1184-1193 says the opposite: under a one-byte locale the shared helper "also skips every row about a git branch". The new paragraph is the true one.

Why a SHOULD. N1's second choice is exactly the docstrings saying these rows skip. This one says they judge, names #1224's N1 to say it, and sits in the helper #1258 tells a row author to use. It is one sentence in a file this PR already changes.

Fix. Make the sentence true, for example: "A branch whose bytes are not UTF-8 (on_a_branch_that_is_not_utf_8) is one in every locale, but under a one-byte locale its row skips first, at skip_where_a_name_cannot_be_not_utf_8's locale question (#1224's N1)."

NIT A: no row holds windows_fsdecode, and the N3 row's kill of G4 rests on it raising

The mutants.

  • M2: windows_fsdecode decodes with surrogateescape, so it returns U+DCFF instead of raising on 0xFF. It survives: helpers and callers, 82 passed.
  • M2 together with RV1209's G4 also survives (82 passed). With a windows_fsdecode that does not raise, the locale asked first lets the row through, and N3's row no longer sees G4.

Fix. Add a row beside the three windows_fsencode rows:

  • it raises UnicodeDecodeError on b"\xff";
  • it gives "caf\u00e9".encode("utf-8") back as "caf\u00e9";
  • it passes a str through.

Then name windows_fsdecode among "the tools the tests below are written with" in the module docstring. I tried such a row in a scratch copy: it passes at this head and kills M2.

NIT B: only Latin-1 holds the two guards to the predicate

The mutants. Invert the helpers guard skip_where_an_earlier_question_skips (M7), or the callers fixture a_system_that_carries_the_byte (M7b).

  • Under UTF-8 every row passes. 5 rows and 18 rows skip in silence, which is what CI runs.
  • Each is killed only under Latin-1 (5 and 13 rows). The body's N4-e and N4-f are likewise Latin-1 kills.

Fix. Add rows that emulate the locale with locale_of:

  • skip_message(skip_where_an_earlier_question_skips) is None for UTF-8 and ASCII, and not None for Latin-1;
  • in the callers file, skip_message(request.getfixturevalue, "a_system_that_carries_the_byte") is None for UTF-8, and not None for Latin-1.

Tried in a scratch copy: they pass at this head and kill M7 and M7b under UTF-8.

NIT C: the N4 rows emulate one one-byte locale only

The mutant. M14 narrows the predicate's locale half to os.fsdecode(b"\xff") == "\u00ff". It survives under UTF-8 and Latin-1. In cp1251 or KOI8-R, where 0xFF is another letter, the helper would skip and the predicate would not, so the guarded rows would fail there.

Fix. Add a cp1251 case to test_an_earlier_question_skips_where_the_helper_skips_before_the_disk, with earlier True: 0xFF is U+044F there. Tried in a scratch copy: it passes at this head and kills M14.

Mutants (mine, beyond the PR's 12)

Each ran alone in the worktree rv1224-mut-wt at this head. After each, the file was put back with git checkout, and its sha256 matched HEAD's blob every time. "h+c" is the helpers and callers files.

Mutant Run Result
M1: the N1 docstring says the helper skips no branch row; code unchanged UTF-8, h+c survives (82 passed): no row reads a docstring, as expected
M2: windows_fsdecode returns U+DCFF instead of raising UTF-8, h+c survives (82 passed): NIT A above
M2 with RV1209's G4 UTF-8, h+c survives (82 passed): NIT A above
M3: the helper's third question (the disk's mkdir and EILSEQ) dropped UTF-8, h+c killed: 19 rows, among them the N4 [utf-8] and [ascii] rows (no FileNotFoundError)
M4: the predicate joins its halves with and UTF-8, h+c killed: [latin-1], and [windows] (UnicodeDecodeError)
M5: the bytes child's environment no longer blanks pin-source overrides UTF-8, spelled killed: the N5 row
M6: the N5 row compares by subset, with the PR's N5-a (AGENT_PROTOCOL_ROOT added) UTF-8, spelled survives (2 passed). This is a check of the row: its equality is what kills N5-a, and the PR uses equality
M7: the helpers guard inverted UTF-8; Latin-1 survives under UTF-8 (41 passed, 5 skipped); killed under Latin-1 (5): NIT B above
M7b: the callers fixture inverted UTF-8; Latin-1 survives under UTF-8 (18 passed, 18 skipped); killed under Latin-1 (13): NIT B above
M8: the locale reason no longer names the encoding UTF-8, helpers killed: the N2 row, by its new ({LATIN_1}) assertion
M14: the predicate's locale half narrowed to == "\u00ff" UTF-8; Latin-1 survives in both: NIT C above
The PR's N3 (G4), run again UTF-8, h+c killed: the N3 row and [windows] (UnicodeDecodeError). Then the callers file's Windows row ends the session with INTERNALERROR (see below)
The PR's N5-a, run again UTF-8, spelled killed: the N5 row
G4 at the base 01ee69763 UTF-8, h+c the helpers file's 42 rows pass (the body's "G4 survives"). With the callers file in the run, the session ends with INTERNALERROR at test_where_windows_cannot_carry_the_byte_directory_named_skips_and_makes_nothing

Merge-trees

git merge-tree --write-tree of this head, at 2026-11-10T23:21Z, all clean:

SonarCloud and CI

  • SonarCloud. The newest sonarqubecloud[bot] comment, and SonarCloud's API for PR 1326 at commit e7359206: the quality gate passed, with 0 new issues, 0 accepted issues, 0 security hotspots and 0.0% duplication.
  • CI. gh pr checks 1326: package passed, tests-git-bash passed, and tests (run 42908344813) completed with success at e7359206.

#1326's body, checked

Every count and claim I ran again holds (I did not run the 7 extra files of the writer's 38-file gate):

Three notes:

  • origin/main is now dcf63b8b9, not a98fe7cb4. The merge is still clean.
  • G4 at the base. "G4 survives (42 passed)" is true of the helpers file alone. With the callers file in the run, the base already ended G4's session with an INTERNALERROR. The PR's row turns that into a clean failure.
  • The family.py defect. The body's reading is close. The mismatch is in PinRollback._legs, which never puts the leg in self.legs; legs_left plays no part. The defect also shows under ASCII today, not only under Latin-1. Details below.

Outside this PR (follow-up candidates for Brett Heap; none filed)

A real defect in scripts/family.py

What is wrong. A failed remove's rollback loses a member's leg whose path is non-ASCII UTF-8, under any locale whose file name encoding is not UTF-8.

The cause. PinRollback._legs (scripts/family.py:8216) reads each leg's path as name.decode("utf-8", "surrogateescape"). It then asks _is_there(self.member / leg / ".git"), which Python encodes in the locale's codec.

  • Under Latin-1, caf U+00E9 's leg becomes caf\xe9's leg, a path that does not exist.
  • Under ASCII it is a UnicodeEncodeError, which _is_there answers False.
  • Either way the leg is never in self.legs. A leg named with a byte that is not UTF-8 (caf\xe9) round-trips through its surrogate and is kept.

Measured with probes of family.py in the test process (local git only, GIT_SSH_COMMAND=false, a stub gh), on the row's own holder:

  • Under UTF-8, PinRollback.legs holds the leg and spec. There are 4 by-hand lines, and _undo_work_tree() puts the leg back on refs/heads/side.
  • Under Latin-1 and under ASCII, legs holds only spec:
    • the by-hand lines are 3, with no word for the leg and no checkout line;
    • _undo_work_tree() leaves the leg with no checkout;
    • it says "members/Thing checked out again ... and spec in it", with no word that the leg was not brought back.

What fails today. Under ASCII the shared helper does not skip, so the 4 [utf8-keeps-shlex-quote-*] rows run at this head, and all 4 fail at assert len(lines) == 4 (4 failed, 74 passed). The test file and family.py are the same blobs on origin/main, so main fails them under ASCII too (read, not run on main). CI runs UTF-8 only.

A direction for the fix. Keep the leg's path as bytes for the file system and the argv, or read it with os.fsdecode. There are 11 decode("utf-8", "surrogateescape") sites in family.py, worth a look in the same change.

Other candidates

Paths

  • Scratch folder _lane4-scratch/tools/run/rv1224/: the runners, mutants.py, suggested.py, the probes, the logs and junit files, and the id comparisons.
  • Clone _lane4-scratch/rv1224-clone, and worktrees _lane4-scratch/rv1224-{base,fc,head,mut,m1302-head,m1302-base,m1302-fc,mmain-head}-wt.

Lane: openreposhape-4 (openRepoShape-4)

… says a branch whose bytes are not UTF-8 skips first under a one-byte locale, at `skip_where_a_name_cannot_be_not_utf_8`'s locale question, and rows hold `windows_fsdecode` (it raises on the byte 0xFF, so the N3 row sees a helper that asks the locale first), both guards of the rows that reach the disk (each asks the predicate, under UTF-8 too) and the predicate under cp1251 (#1224)

The docstring of `skip_where_the_locale_does_not_spell_it_as_utf_8` said a
row about a branch whose bytes are not UTF-8 judges under a one-byte locale
(#1224's N1). The helper skips it there, first.

The rows added, from RV1224's review of #1326:
- `windows_fsdecode` raises `UnicodeDecodeError` on the byte 0xFF, gives the
  UTF-8 bytes of `caf` and U+00E9 back as that text and passes a str through;
  the module docstring of the helpers file names it among its tools. A
  `windows_fsdecode` that returned U+DCFF let the N3 row pass a helper that
  asked the locale first.
- `skip_where_an_earlier_question_skips` and the fixture
  `a_system_that_carries_the_byte` skip under Latin-1 and not under UTF-8 or
  ASCII, with the locale emulated by `locale_of`. Inverted, each skipped rows
  in silence under UTF-8 and failed only under Latin-1.
- `an_earlier_question_skips` is held to the helper under cp1251, where the
  byte 0xFF is U+044F and not U+00FF.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@brettheap

Copy link
Copy Markdown
Contributor Author

FX1224: RV1224's S1 and NITs A to C on #1326. New head 3f668f4f. Please review the delta only.

The delta is one commit, 3f668f4f2, on e73592062: tests/conftest.py (3 lines), tests/test_non_utf8_name_helpers.py and tests/test_non_utf8_name_callers.py. No tool changed, scripts/family.py is not touched, and the new source is ASCII (read back: no byte above 0x7F and no raw control in any added line). The PR body has a new "Fix round (FX1224)" section; the rest of it is as it was.

Items

  • S1. skip_where_the_locale_does_not_spell_it_as_utf_8's docstring now says what RV1224 gave: a branch whose bytes are not UTF-8 is one in every locale, but under a one-byte locale its row skips first, at skip_where_a_name_cannot_be_not_utf_8's locale question (tests/conftest.py: follow-up of PR #1209 (#1196) from its review: the helper's locale skip also catches 80 rows that can judge the tool under a one-byte locale, and four smaller gaps (a Windows failure, an unheld order, a triple predicate, a docstring) #1224's N1). Nothing else in that docstring changed.
  • NIT A. Three rows beside the windows_fsencode rows hold windows_fsdecode: it raises UnicodeDecodeError on the byte 0xFF, it gives the UTF-8 bytes of caf and U+00E9 back as that text, and it passes a str through. The helpers file's docstring now names it among its tools.
  • NIT B. Rows that emulate the locale with locale_of. In the helpers file, test_the_guard_of_the_rows_that_reach_the_disk_asks_the_predicate says skip_message(skip_where_an_earlier_question_skips) is None for [utf-8] and [ascii] and not None for [latin-1]. In the callers file, test_the_fixture_that_lets_the_probe_through_asks_the_predicate says the same of skip_message(request.getfixturevalue, "a_system_that_carries_the_byte") for [utf-8] and [latin-1]. The callers file reads locale_of and the encoding names through import test_non_utf8_name_helpers as name_helpers.
  • NIT C. A [cp1251] case in test_an_earlier_question_skips_where_the_helper_skips_before_the_disk, with earlier True: 0xFF is U+044F there, and the predicate says true as the helper skips. The docstring says so, and a CP1251 constant sits beside UTF_8, LATIN_1, ASCII.

Counts (base e73592062 against this head, by test id, in the landing-gate environment, at most two runs at a time; the four files are the helpers, callers and spelled files and tests/test_repo_hygiene.py)

  • New rows: 9 (helpers 7: 3 windows_fsdecode, 3 guard, 1 [cp1251]; callers 2). Each passes under UTF-8 and under Latin-1.
  • UTF-8: 215 passed against 224 passed, 0 failed. Per file: helpers 46 to 53, callers 36 to 38, spelled 32, hygiene 101.
  • Latin-1 (LOCPATH with en_US.ISO-8859-1, LC_ALL=en_US.ISO-8859-1, PYTHONUTF8=0): 178 passed and 37 skipped against 187 passed and 37 skipped, 0 failed. Helpers 41 passed and 5 skipped to 48 and 5, callers 18 and 18 to 20 and 18, spelled 18 and 14, hygiene 101. No row changes outcome, so none goes from passed to failed; the 9 new rows are the only change.
  • ASCII (LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0), the spelled file: 17 passed and 15 skipped at both heads.
  • tests/test_repo_hygiene.py: 101 passed at both, under UTF-8 and Latin-1.

Mutants, one at a time in a worktree at this head, under UTF-8; each file put back with git checkout and its sha256 checked against HEAD's blob (all matched). The same mutants at e73592062 all survived under UTF-8, as RV1224 found (82 passed; 41 passed and 5 skipped; 18 passed and 18 skipped).

Mutant At e73592062 At this head
M2: windows_fsdecode decodes with surrogateescape survives, 82 passed killed: 1, test_windows_fsdecode_raises_on_a_byte_that_is_not_utf_8 (DID NOT RAISE)
M2 with RV1209's G4 survives, 82 passed killed: 1, the same row
M7: skip_where_an_earlier_question_skips inverted survives, 41 passed and 5 skipped killed: 3, the three guard rows
M7b: a_system_that_carries_the_byte inverted survives, 18 passed and 18 skipped killed: 2, both fixture rows
M14: the predicate's locale half narrowed to U+00FF survives, 82 passed killed: 1, [cp1251]

Merge-trees (git merge-tree --write-tree of this head, 2026-11-11T00:38Z): clean against origin/main a6f1374b0, #1209's head 01ee69763, #1312 5235870f1 and #1302 371264be0.

SonarCloud at 3f668f4f2: quality gate passed, 0 open issues, 0.0% duplication. package passed; tests and tests-git-bash were still running when this was posted.

Not done, as the brief said: scripts/family.py (RV1224's defect in PinRollback._legs) stays a follow-up candidate for Brett Heap; nothing is filed.

Lane: openreposhape-4 (openRepoShape-4)

@brettheap

Copy link
Copy Markdown
Contributor Author

RVD1224: delta review of FX1224's round at 3f668f4f: READY

All eight checks PASS. FX1224's one commit settles RV1224's S1 and NITs A to C and changes nothing else. No MUST, no SHOULD. One optional NIT, which the writer disclosed (below). SonarCloud's quality gate passed at this head. CI's tests was still running when I read it, which is not a failure.

Reviewed head 3f668f4f2533db7655fc7369e238fd092605f05c (gh pr view 1326 --json headRefOid, and git ls-remote agrees), base of the round e735920624150449600d896b8ca29c07415f9455. Environment: the landing gate's (stub gh first on PATH, GH_TOKEN=bogus, empty GH_CONFIG_DIR, empty global git config, GIT_CONFIG_NOSYSTEM=1, git filter-repo on PATH, /usr/bin/python3 -m pytest -p no:cacheprovider, at most two runs at a time, basetemps under /tmp/lane4-rvd1224-bt/). Latin-1 is LOCPATH=.../rv1258/locales LC_ALL=en_US.ISO-8859-1 PYTHONUTF8=0 (Python reports iso8859-1 and reads 0xFF as '\xff'). Counts are by test id from junit files, head against base.

The checks

# Check Result
1 Ancestry PASS
2 The diff PASS
3 S1 PASS
4 NITs A, B, C, and the mutants PASS
5 Counts PASS
6 Merge-trees PASS
7 SonarCloud and CI PASS (tests pending)
8 Body and FX1224's comment PASS

1. Ancestry. git log --format='%H %P %an <%ae> %s' e73592062..3f668f4f2... is one line: 3f668f4f2533db7655fc7369e238fd092605f05c e735920624150449600d896b8ca29c07415f9455 Brett Heap tests/conftest.py: .... One commit, parent e73592062, authored by Brett Heap with the estate's service address. It ends with the Claude Sonnet 5.5 trailer.

2. The diff. git diff --stat e73592062 3f668f4f2 names three files and no other: tests/conftest.py (3 added, 2 removed), tests/test_non_utf8_name_callers.py (23 added), tests/test_non_utf8_name_helpers.py (65 added, 3 removed). I read every hunk. Each one belongs to S1 or A to C:

  • conftest: the S1 sentence, re-wrapped, nothing else in that docstring.
  • helpers: the module docstring's "three tools" and windows_fsdecode (A); the three windows_fsdecode rows (A); the [cp1251] param, its docstring sentence and the CP1251 constant (C); the guard row (B).
  • callers: import test_non_utf8_name_helpers as name_helpers and the fixture row (B).

/usr/bin/python3 -I over the diff's added lines: added lines 91, removed lines 5, bad 0. No byte above 0x7F, no raw control, no CR. git diff --check is silent. Non-ASCII lines in the three files are 22, 1 and 0 at the base and at the head, the same old lines. pyflakes: nothing new (callers' adopter noise is the same set of messages at both). The longest added line is 80 characters, a section comment like the file's existing ones.

3. S1. The docstring of skip_where_the_locale_does_not_spell_it_as_utf_8 now reads: "A branch whose bytes are not UTF-8 (on_a_branch_that_is_not_utf_8) is one in every locale, but under a one-byte locale its row skips first, at skip_where_a_name_cannot_be_not_utf_8's locale question (#1224's N1)." It is true, measured under Latin-1 at the head:

  • tests/test_family_head_by_hand_bytes.py: 53 passed, 8 skipped, and SKIPPED [8] tests/conftest.py:1199: this system's file name encoding (iso8859-1) reads the byte 0xFF as '\xff', not as '\udcff', so a name that holds it is read in as text here. Line 1199 is the pytest.skip of that helper's locale question.
  • tests/test_family_tracking_branch.py and tests/test_bump_leg_branch_and_push_line.py (both reach on_a_branch_that_is_not_utf_8): 49 passed, 23 skipped, and SKIPPED [11] at the same line with the same reason.

4. NITs A, B, C. Each row holds what RV1224 asked:

  • A. test_windows_fsdecode_raises_on_a_byte_that_is_not_utf_8 (UnicodeDecodeError on b"\xff"), test_windows_fsdecode_reads_utf_8_back_as_the_text_it_spells (the UTF-8 bytes of caf and U+00E9 give that text), test_windows_fsdecode_passes_text_through_as_os_fsdecode_does (a str, including "caf\udcff", comes back as it is). The module docstring names windows_fsdecode among the tools.
  • B. Helpers: test_the_guard_of_the_rows_that_reach_the_disk_asks_the_predicate[utf-8|ascii|latin-1], with locale_of: skip_message(skip_where_an_earlier_question_skips) is None for UTF-8 and ASCII, not None for Latin-1. Callers: test_the_fixture_that_lets_the_probe_through_asks_the_predicate[utf-8|latin-1] through request.getfixturevalue("a_system_that_carries_the_byte"), None for UTF-8, not None for Latin-1 (the two cases RV1224 asked for there; ASCII is held through the predicate by the helpers' guard row and the predicate row).
  • C. [cp1251] in test_an_earlier_question_skips_where_the_helper_skips_before_the_disk, earlier True, and a CP1251 constant.

Extra probe, not in the brief: with RV1224's Windows os.fsencode plugin loaded over the helpers file, the 7 new helpers rows pass. Base 37 passed, 4 failed, 5 skipped; head 44 passed, 4 failed, 5 skipped; the same 4 failing ids at both (the LINUX_ONLY rows RV1224 named), no id changes outcome.

Mutants. Each ran alone in rvd1224-mut-wt (head) or rvd1224-base-wt (e73592062), under UTF-8 unless a Latin-1 column says so. After each, the file was put back with git checkout, and its sha256 was compared with git show HEAD:<path>: every one matched, and git status --porcelain is empty in both worktrees after the last run (conftest.py bebf356ffd9c..., helpers 5f87a1c07745..., callers 51291eac7816... at the head).

Mutant At e73592062 At 3f668f4f2
M2: windows_fsdecode decodes with surrogateescape survives, 82 passed killed: 1 failed, 90 passed, test_windows_fsdecode_raises_on_a_byte_that_is_not_utf_8 (DID NOT RAISE UnicodeDecodeError)
M2 with RV1209's G4 survives, 82 passed killed: 1, the same row
M7: helpers guard inverted survives, 41 passed, 5 skipped killed: 3 failed, the three guard rows. Latin-1: 8 failed
M7b: callers fixture inverted survives, 18 passed, 18 skipped killed: 2 failed, both fixture rows. Latin-1: 15 failed
M14: predicate narrowed to U+00FF survives, 82 passed (Latin-1: 59 passed, 23 skipped) killed: 1 failed, [cp1251]. Latin-1: 1 failed too
X1 (mine): windows_fsdecode decodes as Latin-1 not run killed: 3
X2 (mine): windows_fsdecode no longer passes a str through not run killed: 1, the str row
X3 (mine): helpers guard never skips not run killed: 1, [latin-1] (UTF-8); 6 under Latin-1
X4 (mine): callers fixture never skips not run killed: 1, [latin-1] (UTF-8); 14 under Latin-1
V-G4: RV1209's G4 alone not run killed: 2 (..._the_disk_is_not_asked, [windows]), then the callers file's Windows rows end the session with INTERNALERROR, which RV1224 already named as outside this PR
X5 (mine): windows_fsdecode decodes with strict, not surrogatepass not run survives, 91 passed: NIT 1 below

5. Counts. The helpers, callers and spelled files plus tests/test_repo_hygiene.py, base e73592062 against head 3f668f4f2, by id:

Run Base Head By id
UTF-8 215 passed 224 passed, 0 failed the 9 new rows only; 0 outcome changes. Helpers 46 to 53, callers 36 to 38, spelled 32, hygiene 101
Latin-1 178 passed, 37 skipped 187 passed, 37 skipped, 0 failed the 9 new rows only; 0 rows from passed to failed. Helpers 41+5 to 48+5, callers 18+18 to 20+18, spelled 18+14, hygiene 101
ASCII (LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0), the spelled file 17 passed, 15 skipped 17 passed, 15 skipped no id changes

The 9 new ids: helpers 7 (3 windows_fsdecode, 3 guard, 1 [cp1251]) and callers 2, each passing under UTF-8 and Latin-1.

6. Merge-trees (git merge-tree --write-tree of the head, 2026-11-11T00:51Z), all rc=0:

7. SonarCloud and CI at 3f668f4f2:

  • SonarCloud: gh pr checks pass. The newest sonarqubecloud[bot] comment (6783409355) says "Quality Gate passed", 0 new issues, 0 accepted, 0 hotspots, 0.0% duplication. The API agrees: projectStatus OK, PR 1326 at commit 3f668f4f2 with 0 bugs, 0 vulnerabilities, 0 code smells, issues/search open total 0, new_duplicated_lines_density 0.0.
  • CI: package pass, tests-git-bash pass, tests (run 42932935429, started 00:38:30Z) in progress at 00:57Z.

8. Body and FX1224's comment (#1326 issuecomment-6783434420):

Findings

No MUST. No SHOULD.

NIT 1 (optional, disclosed by the writer, outside RV1224's ask): no row pins windows_fsdecode on a surrogate's three-byte form. X5 (strict in place of surrogatepass) survives under UTF-8 (91 passed), as FX1224's report guessed. Nothing in the suite decodes such bytes through it today. If a row is added later: windows_fsdecode(b"caf\xed\xb3\xbf") == "caf\udcff".

Still outside this PR, as RV1224 listed and nothing here changes it: PinRollback._legs in scripts/family.py, and the callers file's Windows rows ending a failing session with INTERNALERROR. None filed.

Paths

  • Clone _lane4-scratch/rvd1224-clone (detached at the head), worktrees _lane4-scratch/rvd1224-mut-wt (head) and _lane4-scratch/rvd1224-base-wt (e73592062).
  • Scratch folder _lane4-scratch/tools/run/rvd1224/: env.sh, run.sh, run-win.sh, runlist.sh, counts.sh, mutants.py, showmut.py, compare.py, check_ascii.py, the junit files, logs and compare outputs under logs/, merge-trees.txt, body-live.md, fx-comment.md, sonar-gate.json, pr-checks.txt.
  • Basetemps: /tmp/lane4-rvd1224-bt/.

Lane: openreposhape-4 (openRepoShape-4)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant