Skip to content

Drop the unusable runtime .ico load from Ludo#17

Merged
DoRmAmMu1997 merged 1 commit into
mainfrom
claude/games-overhaul
Jul 18, 2026
Merged

Drop the unusable runtime .ico load from Ludo#17
DoRmAmMu1997 merged 1 commit into
mainfrom
claude/games-overhaul

Conversation

@DoRmAmMu1997

Copy link
Copy Markdown
Owner

Follow-up to #16, which is already merged. While rebuilding the four executables locally I verified that the Ludo window icon actually loads at runtime, and it does not.

The problem

pygame.image.load("ludo_icon.ico") raises pygame.error: Unsupported ICO bitmap format — SDL_image cannot decode this file. The _load_icon() helper added in #16 therefore caught the error and fell through to the procedural _make_icon() on every run, and datas=[('ludo_icon.ico', '.')] bundled a file into the exe that nothing could read.

So the change was dead code plus a pointless bundled asset. Nothing was visibly broken — the fallback icon is what shipped either way — which is exactly why the test suite and the headless autotest both stayed green through it. Only loading the file directly exposed the failure.

The fix

  • Call _make_icon() directly and document, in its docstring, why the .ico is not loaded at runtime.
  • Delete _load_icon() and _resource_path(), which existed only to serve it.
  • Set datas=[] in the spec with a comment explaining that the .ico is consumed by PyInstaller rather than at runtime.

The .exe file and taskbar icon is unaffected. That comes from the spec's separate icon=['ludo_icon.ico'] argument, which PyInstaller embeds itself; it predates #16 and is untouched here.

For contrast, Monopoly's equivalent runtime icon load works because it uses a .png (verified: loads fine at 256x256). The resource-path pattern is sound — the .ico format was the problem.

Verification

  • ruff check . clean; mypy "Python Ludo Game" clean (sys and Path are still used elsewhere in the module, so no orphaned imports).
  • Ludo suite green, 28 passed, coverage 81.32% against the 75 floor.
  • Rebuilt Ludo Game.exe from the fixed spec and ran it with LUDO_AUTOTEST=1; exits 0.
  • All four exes rebuilt and smoke-tested: the three pygame games exit 0 from their packaged binaries, and Solitaire's window stays alive.

Note on the branch

This reuses claude/games-overhaul, whose previous PR (#16) was merged and the branch deleted. I pushed this commit before noticing the merge, which re-created the branch. GitHub computes the diff against current main, so this PR contains only the two files above. The branch can be deleted again on merge.

🤖 Generated with Claude Code

Verified while rebuilding the executables: SDL_image cannot decode
ludo_icon.ico ("Unsupported ICO bitmap format"), so the _load_icon()
helper added earlier in this branch always fell through to the
procedural icon. The bundled datas entry shipped a file nothing could
read, and _resource_path existed only to find it.

Remove both and call _make_icon() directly, documenting why the .ico is
not loaded at runtime. The .exe file/taskbar icon is unaffected: it
comes from the spec's separate icon= argument, which PyInstaller embeds
itself. (Monopoly's equivalent uses a .png, which pygame loads fine.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@DoRmAmMu1997
DoRmAmMu1997 merged commit 4ffa493 into main Jul 18, 2026
2 checks passed
@DoRmAmMu1997
DoRmAmMu1997 deleted the claude/games-overhaul branch July 18, 2026 10:38
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