Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions bblfsh/pyuast.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,22 @@ static PyObject *PyFilter(PyObject *self, PyObject *args)
return NULL;

Nodes *nodes = UastFilter(ctx, obj, query);
if (nodes) {
int len = NodesSize(nodes);
PyObject *list = PyList_New(len);

for (int i = 0; i < len; i++) {
PyObject *node = (PyObject *)NodeAt(nodes, i);
Py_INCREF(node);
PyList_SET_ITEM(list, i, node);
}
NodesFree(nodes);
return PySeqIter_New(list);
if (!nodes) {
char *error = LastError();
PyErr_SetString(PyExc_RuntimeError, error);
free(error);
return NULL;
}
int len = NodesSize(nodes);
PyObject *list = PyList_New(len);

for (int i = 0; i < len; i++) {
PyObject *node = (PyObject *)NodeAt(nodes, i);
Py_INCREF(node);
PyList_SET_ITEM(list, i, node);
}
NodesFree(nodes);
return PySeqIter_New(PyList_New(0));
return PySeqIter_New(list);
}

static PyMethodDef extension_methods[] = {
Expand Down
5 changes: 1 addition & 4 deletions bblfsh/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def testUASTFileContents(self):
self._validate_filter(uast)

def testBrokenFilter(self):
from sys import version_info
if version_info[0:2] != (3, 4):
# Skip test 3.4: cant capture SystemException from binary modules
self.assertRaises(SystemError, filter, 0, "foo")
self.assertRaises(RuntimeError, filter, 0, "foo")

def testFilterInternalType(self):
node = Node()
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext

LIBUAST_VERSION = "v1.3.0"
LIBUAST_VERSION = "v1.4.1"
SDK_VERSION = "v1.4.2"
SDK_MAJOR = SDK_VERSION.split('.')[0]
PYTHON = "python3"
Expand Down Expand Up @@ -123,7 +123,7 @@ def main():
'bblfsh.pyuast',
libraries=libraries,
library_dirs=['/usr/lib', '/usr/local/lib'],
extra_compile_args=['-std=c99'],
extra_compile_args=['-std=gnu99'],
include_dirs=['bblfsh/libuast/', '/usr/local/include', '/usr/local/include/libxml2',
'/usr/include', '/usr/include/libxml2'], sources=sources)

Expand Down