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

Open
opened 2026-11-26 20:21:02 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1347
Author: @PierreEbele
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: make-game-pick-fsdecode


📝 Commits (1)

  • 82d0dfc make_game: a folder chosen in kdialog/zenity whose name is not valid in the locale encoding no longer stops --pick (MAKE-GAME-PICK-FSDECODE)

📊 Changes

2 files changed (+103 additions, -4 deletions)

View changed files

📝 make_game.py (+17 -4)
➕ tests/test_make_game_pick_fsdecode.py (+86 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1347 **Author:** [@PierreEbele](https://github.com/PierreEbele) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `make-game-pick-fsdecode` --- ### 📝 Commits (1) - [`82d0dfc`](https://github.com/ubiquitarianism/leonida/commit/82d0dfcc40f5af0a72cc99d247c9fa707284bae6) make_game: a folder chosen in kdialog/zenity whose name is not valid in the locale encoding no longer stops --pick (MAKE-GAME-PICK-FSDECODE) ### 📊 Changes **2 files changed** (+103 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `make_game.py` (+17 -4) ➕ `tests/test_make_game_pick_fsdecode.py` (+86 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1377
No description provided.