Skip to content

go() in the #241 tests inherits the caller's locale, so the rows that expect a misdrawn character in a directory to be refused pass or fail by the developer's own charmap #320

Open

Description

@brettheap

What happens

go() (tests/test_install_unprintable_values_241.py:293-313 at 4c7ded8, the head of #241's branch when this was filed) builds its environment with command_env (tests/test_openrepotools_command.py:170-208). That copies os.environ, drops the OPENREPOTOOLS_* names, XDG_DATA_HOME, CLAUDE_PROFILES_HOME, CLAUDE_USER_DIR, AGENT_PROTOCOL_ROOT and PROJECTS_DIR, and applies the case's env. Neither file clears or sets LANG, LC_ALL or LC_CTYPE for a run. Line numbers are at 4c7ded8, in the test file unless the text says openRepoTools.

The installer asks the person's own locale about a directory, and only a directory: refuse_bad_bin_dir calls value_fault "$dir" locale (openRepoTools:5456), and locale_reading (openRepoTools:5387-5404) runs locale charmap, which reads LC_ALL, LC_CTYPE and LANG. Where a multibyte charmap that is not UTF-8 reads the bytes of a misdrawn character or a C1 control as text, the directory is taken, not refused. That is the design (openRepoShape issue 858: the locale is taken at its word). The repository and the ref never ask (openRepoTools:5487, :5492).

So a case that passes a directory holding a misdrawn character and no LC_ALL expects a refusal that holds only under a UTF-8 or C locale. Collecting the ids at 4c7ded8 and reading what each passes gives 51 items:

  • test_each_misdrawn_character_is_refused_by_its_code_point[...-the-directory], 41 (:474-488). Its docstring says "the locale changes nothing", which holds for the repository and the ref and not for the directory.
  • The U+202E rows of UNNAMEABLE_BIN_DIRS (2, :398-403), of BAD_HOMES (:436-437; 2 tests, --install at :441-453 and wip init at :832-847) and of WIP_BAD_DIRS (:780-781; 6 items, three routes with and without --dry-run).

The cases that name a locale (LC_ALL over LOCALES, and the marker-locale section from :1002) are not exposed.

Measured, with a stand-in locale first on PATH that answers each charmap and the real iconv: the installer at 4c7ded8, --install, gh and curl failing, for each of the 41 code points as <home>/a<char>forged.

locale charmap says refused at the door went on (taken)
UTF-8, or ANSI_X3.4-1968 (C) 41 0
EUC-JP, EUC-KR 40 1 (U+00AD)
Big5 36 5
Shift_JIS 15 26
GBK 7 34
GB18030 1 40

U+202E is taken under GB18030, GBK and Shift_JIS. The full installer ran for UTF-8, GB18030 and Shift_JIS; the other rows come from value_fault, the installer's own function, whose answers matched the installer's wherever both ran.

CI's UTF-8 locale is unaffected, and so is a developer whose locale is UTF-8 or C. A developer whose shell exports a GB18030, GBK or Shift_JIS locale (installed) would see dozens of these rows fail for a reason that has nothing to do with the change under test.

Not run: the test module under a real multibyte locale. None is installed here (locale -a lists C, C.utf8 and POSIX) and, as the module says (:1006), none is on CI.

Suggested fix

Pin the locale in go() unless the case names one: pass {"LC_ALL": "C.UTF-8", **(env or {})} to command_env. A case that sets LC_ALL keeps its own, and the_persons_locale's empty LC_ALL (:1053-1056) still wins. C would do as well; both are in LOCALES. Pinning command_env instead would cover every install test that shares it.

To see the fix work without a multibyte locale installed: put put_a_locale's locale stub first on the pytest process's PATH and export LANG=xx_XX.GB18030. The items above should fail before the pin and pass after it.

Found by: the first independent review of #241 (NIT 3, 2026-10-22) and its re-review, which says the follow-up is worth doing (2026-10-22). Filed on Brett Heap's word of 2026-10-23T14:21:33Z, by multiple choice: "Pin LC_ALL in go()".

Lane: openRepoTools-5

Activity

  1. brettheap commented on Oct 24, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoTools-5, session 0d83dca2-c18c-4bb0-99ce-896e6cafea02@Eagle, 2026-10-24T14:18:13Z, for #320

    Logged in lanes/log/openRepoTools-5.md at 71a7cdd13f7fd76ad606bd430f108101d570ae66.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoTools#320:
       none
    2. `gh pr list --repo opensoft/openRepoTools --state all --search "#320"`, kept where the row or its body names `#320`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoTools` branches naming `320` as a whole token:
       none
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions