diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c index aaa4fd3e8..4f2e7765f 100644 --- a/src/runtime/python/pypgf.c +++ b/src/runtime/python/pypgf.c @@ -1917,6 +1917,10 @@ PGF_categoryContext(PGFObject *self, PyObject *args) return NULL; } + if (hypos == NULL) { + Py_RETURN_NONE; + } + PyObject *contexts = PyList_New(n_hypos); if (contexts == NULL) { return NULL; diff --git a/src/runtime/python/test_suite.py b/src/runtime/python/test_suite.py index 47e420327..d0699ecee 100644 --- a/src/runtime/python/test_suite.py +++ b/src/runtime/python/test_suite.py @@ -98,7 +98,7 @@ def test_categoryContext_3(PGF): assert tup[2] == pgf.readType("N") def test_categoryContext_4(PGF): - assert PGF.categoryContext("X") == [] + assert PGF.categoryContext("X") == None def test_functionIsConstructor_1(PGF): assert PGF.functionIsConstructor("s") == True