forked from GitHub/gf-core
Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#define PyString_Check PyUnicode_Check
|
||||
#define PyString_FromString PyUnicode_FromString
|
||||
#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
|
||||
#define PyString_FromFormat PyUnicode_FromFormat
|
||||
#define PyString_Concat(ps,s) {PyObject* tmp = *(ps); *(ps) = PyUnicode_Concat(tmp,s); Py_DECREF(tmp);}
|
||||
@@ -2867,7 +2866,7 @@ static PyObject*
|
||||
PGF_getAbstractName(PGFObject *self, void *closure)
|
||||
{
|
||||
PgfText* txt = pgf_abstract_name(self->pgf);
|
||||
return PyString_FromString(txt->text);
|
||||
return PyString_FromStringAndSize(txt->text, txt->size);
|
||||
}
|
||||
|
||||
// static void
|
||||
@@ -2965,14 +2964,14 @@ pgf_collect_cats(PgfItor* fn, PgfText* key, void* value, PgfExn *err)
|
||||
|
||||
PyObject* py_name = NULL;
|
||||
|
||||
py_name = PyString_FromString(name->text);
|
||||
py_name = PyString_FromStringAndSize(name->text, name->size);
|
||||
if (py_name == NULL) {
|
||||
// gu_raise(err, PgfExn);
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (PyList_Append((PyObject*) clo->collection, py_name) != 0) {
|
||||
// gu_raise(err, PgfExn);
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -2990,6 +2989,10 @@ PGF_getCategories(PGFObject *self, void *closure)
|
||||
PgfExn err;
|
||||
PyPGFClosure clo = { { pgf_collect_cats }, self, categories };
|
||||
pgf_iter_categories(self->pgf, &clo.fn, &err);
|
||||
if (err.type != PGF_EXN_NONE) {
|
||||
Py_DECREF(categories);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return categories;
|
||||
}
|
||||
@@ -3022,14 +3025,14 @@ pgf_collect_funs(PgfItor* fn, PgfText* key, void* value, PgfExn *err)
|
||||
|
||||
PyObject* py_name = NULL;
|
||||
|
||||
py_name = PyString_FromString(name->text);
|
||||
py_name = PyString_FromStringAndSize(name->text, name->size);
|
||||
if (py_name == NULL) {
|
||||
// gu_raise(err, PgfExn);
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (PyList_Append((PyObject*) clo->collection, py_name) != 0) {
|
||||
// gu_raise(err, PgfExn);
|
||||
err->type = PGF_EXN_OTHER_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -3047,13 +3050,10 @@ PGF_getFunctions(PGFObject *self, void *closure)
|
||||
PgfExn err;
|
||||
PyPGFClosure clo = { { pgf_collect_funs }, self, functions };
|
||||
pgf_iter_functions(self->pgf, &clo.fn, &err);
|
||||
// if (!gu_ok(err)) {
|
||||
// Py_DECREF(functions);
|
||||
// gu_pool_free(tmp_pool);
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// gu_pool_free(tmp_pool);
|
||||
if (err.type != PGF_EXN_NONE) {
|
||||
Py_DECREF(functions);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return functions;
|
||||
}
|
||||
@@ -3079,13 +3079,10 @@ PGF_functionsByCat(PGFObject* self, PyObject *args)
|
||||
PgfExn err;
|
||||
PyPGFClosure clo = { { pgf_collect_funs }, self, functions };
|
||||
pgf_iter_functions_by_cat(self->pgf, catname, &clo.fn, &err);
|
||||
// if (!gu_ok(err)) {
|
||||
// Py_DECREF(functions);
|
||||
// gu_pool_free(tmp_pool);
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// gu_pool_free(tmp_pool);
|
||||
if (err.type != PGF_EXN_NONE) {
|
||||
Py_DECREF(functions);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return functions;
|
||||
}
|
||||
@@ -3722,7 +3719,7 @@ MOD_INIT(pgf)
|
||||
Py_INCREF(PGFError);
|
||||
|
||||
PyObject *dict = PyDict_New();
|
||||
PyDict_SetItemString(dict, "token", PyString_FromString(""));
|
||||
PyDict_SetItemString(dict, "token", PyString_FromStringAndSize("", 0));
|
||||
ParseError = PyErr_NewException("pgf.ParseError", NULL, dict);
|
||||
PyModule_AddObject(m, "ParseError", ParseError);
|
||||
Py_INCREF(ParseError);
|
||||
|
||||
Reference in New Issue
Block a user