make_game: a folder whose name the locale cannot decode no longer stops --pick on Linux (MAKE-GAME-PICK-FSDECODE) #1347

Merged
PierreEbele merged 1 commit from upstream-pr/1347 into main 2026-11-29 00:45:38 +00:00
PierreEbele commented 2026-11-24 22:07:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T22:07:08Z.


On Linux and the BSDs, --pick opens the desktop's folder dialog through kdialog or zenity (native_ask, make_game.py). Its answer was read with subprocess.run(..., text=True), so choosing a folder whose name is not valid in the locale's encoding (e.g. bytes b"/tmp/caf\xe9" under a UTF-8 locale) raised UnicodeDecodeError, which pick_game does not catch (it only expects OSError from the tool), and the build stopped with a traceback.

What changes:

  • native_ask reads the answer as bytes and decodes it with os.fsdecode, so the path round-trips (os.fsencode gives back the bytes the dialog printed). Return codes keep their meaning (1 = cancelled, other non-zero = OSError).
  • print()ing such a str on a UTF-8 terminal raises UnicodeEncodeError, so the two chose ... in <folder> log lines go through a new show_path() that shows the undecodable bytes escaped (/tmp/caf\xe9). Display only: the path handed to the build is unchanged.
  • New tests/test_make_game_pick_fsdecode.py (CPU only, no display, no game files): a stand-in kdialog printing raw bytes, show_path against a strict UTF-8 stream, and pick_game end to end with a mocked dialog. Windows is skipped (the native dialogs never run there); the stand-in test skips itself when the temp folder is mounted noexec.

Tested on Linux arm64, no network, Python 3.12, python3 -I:

  • New test on main 4a50cafc: FAILED (errors=5), including UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in native_ask.
  • On this branch: Ran 5 tests ... OK (with an executable TMPDIR); tests/test_make_game_pick.py OK; make_game.py --help OK; scripts/check_no_game_data.py clean on both files.

Takes the finding posted by Snooozs in #14 (read in the code there, reproduced here).

AI-assisted (Claude Code and Mistral Vibe).

Claimed in the coordination issue as: MAKE-GAME-PICK-FSDECODE

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481131488 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1347). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-24T22:07:08Z. --- On Linux and the BSDs, `--pick` opens the desktop's folder dialog through kdialog or zenity (`native_ask`, `make_game.py`). Its answer was read with `subprocess.run(..., text=True)`, so choosing a folder whose name is not valid in the locale's encoding (e.g. bytes `b"/tmp/caf\xe9"` under a UTF-8 locale) raised `UnicodeDecodeError`, which `pick_game` does not catch (it only expects `OSError` from the tool), and the build stopped with a traceback. What changes: - `native_ask` reads the answer as bytes and decodes it with `os.fsdecode`, so the path round-trips (`os.fsencode` gives back the bytes the dialog printed). Return codes keep their meaning (1 = cancelled, other non-zero = `OSError`). - `print()`ing such a str on a UTF-8 terminal raises `UnicodeEncodeError`, so the two `chose ... in <folder>` log lines go through a new `show_path()` that shows the undecodable bytes escaped (`/tmp/caf\xe9`). Display only: the path handed to the build is unchanged. - New `tests/test_make_game_pick_fsdecode.py` (CPU only, no display, no game files): a stand-in kdialog printing raw bytes, `show_path` against a strict UTF-8 stream, and `pick_game` end to end with a mocked dialog. Windows is skipped (the native dialogs never run there); the stand-in test skips itself when the temp folder is mounted `noexec`. Tested on Linux arm64, no network, Python 3.12, `python3 -I`: - New test on `main` 4a50cafc: `FAILED (errors=5)`, including `UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9` in `native_ask`. - On this branch: `Ran 5 tests ... OK` (with an executable `TMPDIR`); `tests/test_make_game_pick.py` OK; `make_game.py --help` OK; `scripts/check_no_game_data.py` clean on both files. Takes the finding posted by Snooozs in #14 (read in the code there, reproduced here). AI-assisted (Claude Code and Mistral Vibe). Claimed in the coordination issue as: MAKE-GAME-PICK-FSDECODE 🤖 Generated with [Claude Code](https://claude.com/claude-code)
whoalin1 commented 2026-11-24 23:40:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T23:40:09Z.


Verified on Windows host (AI-assisted review).

  • python -I tests/test_make_game_pick_fsdecode.py: 5 tests, 3 skipped (they target kdialog/zenity, which never run on Windows), 2 pass — the non-dialog show_path() unit tests.
  • python -I -m compileall make_game.py clean; python -I make_game.py --help prints usage; tests/test_text_write_line_endings.py still passes.
  • The change is confined to the non-Windows dialog path (native_ask bytes + os.fsdecode, show_path used only in the log line), so Windows-native behaviour is unchanged by inspection: subprocess.run without text=True returns bytes and os.fsdecode is a no-op round-trip for valid encodings. Cannot exercise the surrogateescape path on Windows; the skipped tests cover it on Linux.

Verdict: looks correct, no Windows regressions found. The real verification needs a Linux CI run for the 3 skipped tests.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147662197 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1347#issuecomment-7147662197). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-24T23:40:09Z. --- Verified on Windows host (AI-assisted review). - `python -I tests/test_make_game_pick_fsdecode.py`: 5 tests, 3 skipped (they target kdialog/zenity, which never run on Windows), 2 pass — the non-dialog show_path() unit tests. - `python -I -m compileall make_game.py` clean; `python -I make_game.py --help` prints usage; `tests/test_text_write_line_endings.py` still passes. - The change is confined to the non-Windows dialog path (native_ask bytes + os.fsdecode, show_path used only in the log line), so Windows-native behaviour is unchanged by inspection: subprocess.run without text=True returns bytes and os.fsdecode is a no-op round-trip for valid encodings. Cannot exercise the surrogateescape path on Windows; the skipped tests cover it on Linux. Verdict: looks correct, no Windows regressions found. The real verification needs a Linux CI run for the 3 skipped tests.
zmasi commented 2026-11-28 22:29:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:29:12Z.


Native Windows 11 Verification (82d0dfcc40)

Verified 82d0dfcc40f5af0a72cc99d247c9fa707284bae6 merged cleanly onto origin/main (adfb3821a23612263c1c5b195453ed01c4c114db, git merge-tree --write-tree rc=0) on native Windows 11 (26200):

  • Red (origin/main adfb3821a): python -I tests/test_make_game_pick_fsdecode.py failed (FAILED (errors=2, skipped=3)).
  • Green (origin/main + 82d0dfcc40): python -I tests/test_make_game_pick_fsdecode.py passed (5 ran, OK (skipped=3) — confirming ShowPathTest escapes lone surrogates cleanly on Windows under surrogatepass without raising UnicodeEncodeError on strict UTF-8 streams, while skipping the Linux kdialog/zenity dialog tests cleanly on os.name == "nt").

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246768281 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1347#issuecomment-7246768281). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:29:12Z. --- ### Native Windows 11 Verification (`82d0dfcc40`) Verified `82d0dfcc40f5af0a72cc99d247c9fa707284bae6` merged cleanly onto `origin/main` (`adfb3821a23612263c1c5b195453ed01c4c114db`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`)**: - **Red (`origin/main` `adfb3821a`)**: `python -I tests/test_make_game_pick_fsdecode.py` failed (`FAILED (errors=2, skipped=3)`). - **Green (`origin/main + 82d0dfcc40`)**: `python -I tests/test_make_game_pick_fsdecode.py` passed (`5 ran, OK (skipped=3)` — confirming `ShowPathTest` escapes lone surrogates cleanly on Windows under `surrogatepass` without raising `UnicodeEncodeError` on strict UTF-8 streams, while skipping the Linux `kdialog`/`zenity` dialog tests cleanly on `os.name == "nt"`). AI-assisted.
TheGeogeo commented 2026-11-29 00:17:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:34Z.


Tested 82d0dfcc4 merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_make_game_pick_fsdecode.py, 5 tests pass (3 skipped).
  • Red: with make_game.py back to main, 2 errors (module 'make_game' has no attribute 'show_path').

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248010727 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1347#issuecomment-7248010727). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:34Z. --- Tested `82d0dfcc4` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_make_game_pick_fsdecode.py`, 5 tests pass (3 skipped). - Red: with `make_game.py` back to `main`, 2 errors (`module 'make_game' has no attribute 'show_path'`). No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 00:45:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:45:41Z.


Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto main 6d004cc68 without conflict, and its test file(s) (tests/test_make_game_pick_fsdecode.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248332618 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1347#issuecomment-7248332618). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T00:45:41Z. --- Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1347#issuecomment-7248010727)) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 6d004cc68 without conflict, and its test file(s) (`tests/test_make_game_pick_fsdecode.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1347
No description provided.