From 54f923a0cb2e86aa51b2242d004f772419c08c1d Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Wed, 15 May 2024 16:20:40 +0300 Subject: [PATCH] fix(tree): return None if node is null --- tree_sitter/binding/tree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tree_sitter/binding/tree.c b/tree_sitter/binding/tree.c index b43d5b1..b6f7a85 100644 --- a/tree_sitter/binding/tree.c +++ b/tree_sitter/binding/tree.c @@ -36,6 +36,9 @@ PyObject *tree_root_node_with_offset(Tree *self, PyObject *args) { ModuleState *state = GET_MODULE_STATE(self); TSNode node = ts_tree_root_node_with_offset(self->tree, offset_bytes, offset_extent); + if (ts_node_is_null(node)) { + Py_RETURN_NONE; + } return node_new_internal(state, node, (PyObject *)self); }