tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
360 stars 132 forks source link

bug: v0.23.0 breaks `Language(tspython.language())` #280

Closed jonathanhar closed 3 weeks ago

jonathanhar commented 3 weeks ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

In the new version, tspython.language() does nut output an integer, but rather capsule object "tree_sitter.Language"

Steps To Reproduce/Bad Parse Tree

  1. pip install git+https://github.com/tree-sitter/tree-sitter-python.git@master
  2. Run:
    
    import tree_sitter_python as tspython
    from tree_sitter import Language

PY_LANGUAGE = Language(tspython.language())


### Expected Behavior/Parse Tree

in v0.21.0 it would work

### Repro

```Python
# Example code that causes the issue
def foo():
  # Code that fails to parse, or causes an error
  ...
jonathanhar commented 3 weeks ago

Thanks @almahdi404 ! I'm using Python, what's the right way to approach this then?

almahdi404 commented 3 weeks ago

The latest version of py-tree-sitter(tree-sitter) failed to be released(https://github.com/tree-sitter/py-tree-sitter/actions/runs/10562867186/job/29262209830).

Use these versions, until they publish tree-sitter==0.23.0

pip install tree-sitter==0.22.3 tree-sitter-python==0.21.0
ericwb commented 3 weeks ago

If a backwards incompatible change will be made like this (for those of us using Python at least), it is better to document prior to a new tag/release. Ideally go through a deprecation cycle. Also, other tree-sitter languages will also need a new tag, such as tree-sitter-java.