Skip to content

Commit

Permalink
fix(language): use uintptr_t
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed May 18, 2024
1 parent a82d764 commit af5c27a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setUp(self):
self.rust = tree_sitter_rust.language()

def test_init_invalid(self):
self.assertRaises(ValueError, Language, -1)
self.assertRaises(ValueError, Language, 42)

def test_properties(self):
Expand Down
4 changes: 2 additions & 2 deletions tree_sitter/binding/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ int language_init(Language *self, PyObject *args, PyObject *Py_UNUSED(kwargs)) {
if (!PyArg_ParseTuple(args, "O:__init__", &language)) {
return -1;
}
Py_ssize_t language_id = PyLong_AsSsize_t(language);
if (language_id < 1 || (language_id % sizeof(TSLanguage *)) != 0) {
Py_uintptr_t language_id = PyLong_AsUnsignedLong(language);
if (language_id == 0 || (language_id % sizeof(TSLanguage *)) != 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "invalid language ID");
}
Expand Down

0 comments on commit af5c27a

Please sign in to comment.