Skip to content

fix: handle encoding in load_gitignores (issue #2888)#5362

Open
chrislazar25 wants to merge 1 commit into
Aider-AI:mainfrom
chrislazar25:fix/issue-2888
Open

fix: handle encoding in load_gitignores (issue #2888)#5362
chrislazar25 wants to merge 1 commit into
Aider-AI:mainfrom
chrislazar25:fix/issue-2888

Conversation

@chrislazar25

@chrislazar25 chrislazar25 commented Jun 30, 2026

Copy link
Copy Markdown

Summary: Fix UnicodeDecodeError when loading .gitignore files containing UTF-8 non-ASCII characters on Windows by specifying encoding='utf-8'.

Technical Details:

  • Root Cause: load_gitignores() in watch.py opens .gitignore with plain open(path), letting Python fall back to the OS default encoding (cp1252 on Windows). A byte like 0x9d in a UTF-8 Cyrillic comment triggers UnicodeDecodeError.
  • Mechanism: .gitignore files are conventionally UTF-8. Adding encoding='utf-8', errors='replace' matches convention and safely handles edge-case bytes that would be non-UTF-8.

Verification: Confirmed adherence to CONTRIBUTING.md. Ran python -m pytest tests/ -x -q. 455 passed, 1 failed (test_voice_init_invalid_format pre-existing, requires audio hardware). Pre-commit hooks (isort, black, flake8, codespell) all green.

Blast Radius:

  • Impact: Low. Only affects .gitignore file reads in the FileWatcher init path.
  • Trade-offs: errors='replace' substitutes replacement characters (�) for genuinely non-UTF-8 bytes, which could only occur in comments. ignore patterns are ASCII-safe.

Fixes #2888

@chrislazar25 chrislazar25 marked this pull request as ready for review June 30, 2026 17:09
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.

Uncaught UnicodeDecodeError in cp1252.py line 23

1 participant