Skip to content

fix: handle tree-sitter parse() str/bytes contract on Python 3.14#5179

Open
Mramaran wants to merge 1 commit into
Aider-AI:mainfrom
Mramaran:fix-tree-sitter-parse-py314
Open

fix: handle tree-sitter parse() str/bytes contract on Python 3.14#5179
Mramaran wants to merge 1 commit into
Aider-AI:mainfrom
Mramaran:fix-tree-sitter-parse-py314

Conversation

@Mramaran
Copy link
Copy Markdown
Contributor

@Mramaran Mramaran commented May 23, 2026

Summary

On Python 3.14, tree-sitter's Parser.parse() rejects bytes arguments with
TypeError: argument 'source': 'bytes' object is not an instance of 'str',
while the version aider pins (tree-sitter==0.25.2) accepts only bytes.

This wraps both parser.parse(bytes(code, "utf-8")) call sites with a
try/except TypeError that falls back to passing the raw string, so aider
works on both contracts without changing the pinned dependency.

Files changed

  • aider/repomap.py (line 299)
  • aider/linter.py (line 220)

Test plan

  • pytest tests/basic/test_repomap.py tests/basic/test_linter.py — 52/52 pass on Python 3.13.5
  • Full pytest — 446 passed (1 unrelated Windows symlink-permission failure on local env, not present in CI)
  • Pre-commit hooks pass: black, isort, flake8, codespell
  • Fallback logic verified by simulating both contract directions
  • Original reporters to confirm on Python 3.14

Closes #5174
Closes #5164

On Python 3.14, tree-sitter's Parser.parse() rejects bytes and requires str, while the version pinned by aider (tree-sitter==0.25.2) accepts only bytes. Wrap the parse() call in try/except so both contracts work without changing the pinned dependency.

Closes Aider-AI#5174
Closes Aider-AI#5164
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 TypeError in repomap.py line 299 Uncaught TypeError in linter.py line 220

1 participant