silence warnings in the Python bindings

This commit is contained in:
krangelov
2019-12-07 10:27:06 +01:00
parent f1f47f7281
commit bb298fadbe

View File

@@ -1307,8 +1307,8 @@ static PyObject*
Concr_printName(ConcrObject* self, PyObject *args) Concr_printName(ConcrObject* self, PyObject *args)
{ {
GuString id; GuString id;
if (!PyArg_ParseTuple(args, "s", &id)) if (!PyArg_ParseTuple(args, "s", &id))
return NULL; return NULL;
GuString name = pgf_print_name(self->concr, id); GuString name = pgf_print_name(self->concr, id);
if (name == NULL) if (name == NULL)
@@ -1490,7 +1490,7 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds)
int max_count = -1; int max_count = -1;
double heuristics = -1; double heuristics = -1;
PyObject* py_callbacks = NULL; PyObject* py_callbacks = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|OidO!", kwlist, if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|OidO!", kwlist,
&sentence, &start, &max_count, &sentence, &start, &max_count,
&heuristics, &heuristics,
&PyList_Type, &py_callbacks)) &PyList_Type, &py_callbacks))
@@ -1586,10 +1586,10 @@ Concr_complete(ConcrObject* self, PyObject *args, PyObject *keywds)
PyObject* start = NULL; PyObject* start = NULL;
GuString prefix = ""; GuString prefix = "";
int max_count = -1; int max_count = -1;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|Osi", kwlist, if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|Osi", kwlist,
&sentence, &start, &sentence, &start,
&prefix, &max_count)) &prefix, &max_count))
return NULL; return NULL;
IterObject* pyres = (IterObject*) IterObject* pyres = (IterObject*)
pgf_IterType.tp_alloc(&pgf_IterType, 0); pgf_IterType.tp_alloc(&pgf_IterType, 0);
@@ -1681,9 +1681,9 @@ Concr_lookupSentence(ConcrObject* self, PyObject *args, PyObject *keywds)
const char *sentence = NULL; const char *sentence = NULL;
PyObject* start = NULL; PyObject* start = NULL;
int max_count = -1; int max_count = -1;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|O", kwlist, if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|O", kwlist,
&sentence, &start, &max_count)) &sentence, &start, &max_count))
return NULL; return NULL;
IterObject* pyres = (IterObject*) IterObject* pyres = (IterObject*)
pgf_IterType.tp_alloc(&pgf_IterType, 0); pgf_IterType.tp_alloc(&pgf_IterType, 0);
@@ -2346,8 +2346,8 @@ pypgf_collect_morpho(PgfMorphoCallback* self,
static PyObject* static PyObject*
Concr_lookupMorpho(ConcrObject* self, PyObject *args) { Concr_lookupMorpho(ConcrObject* self, PyObject *args) {
GuString sent; GuString sent;
if (!PyArg_ParseTuple(args, "s", &sent)) if (!PyArg_ParseTuple(args, "s", &sent))
return NULL; return NULL;
GuPool *tmp_pool = gu_local_pool(); GuPool *tmp_pool = gu_local_pool();
GuExn* err = gu_exn(tmp_pool); GuExn* err = gu_exn(tmp_pool);
@@ -2442,9 +2442,9 @@ Concr_fullFormLexicon(ConcrObject* self, PyObject *args)
static PyObject* static PyObject*
Concr_load(ConcrObject* self, PyObject *args) Concr_load(ConcrObject* self, PyObject *args)
{ {
const char *fpath; const char *fpath;
if (!PyArg_ParseTuple(args, "s", &fpath)) if (!PyArg_ParseTuple(args, "s", &fpath))
return NULL; return NULL;
GuPool* tmp_pool = gu_local_pool(); GuPool* tmp_pool = gu_local_pool();
@@ -2831,8 +2831,8 @@ static PyObject*
PGF_functionsByCat(PGFObject* self, PyObject *args) PGF_functionsByCat(PGFObject* self, PyObject *args)
{ {
PgfCId catname; PgfCId catname;
if (!PyArg_ParseTuple(args, "s", &catname)) if (!PyArg_ParseTuple(args, "s", &catname))
return NULL; return NULL;
PyObject* functions = PyList_New(0); PyObject* functions = PyList_New(0);
if (functions == NULL) { if (functions == NULL) {
@@ -2888,9 +2888,9 @@ PGF_generateAll(PGFObject* self, PyObject *args, PyObject *keywds)
PyObject* start = NULL; PyObject* start = NULL;
int max_count = -1; int max_count = -1;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|i", kwlist, if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|i", kwlist,
&start, &max_count)) &start, &max_count))
return NULL; return NULL;
IterObject* pyres = (IterObject*) IterObject* pyres = (IterObject*)
pgf_IterType.tp_alloc(&pgf_IterType, 0); pgf_IterType.tp_alloc(&pgf_IterType, 0);
@@ -3152,12 +3152,12 @@ static PyObject*
PGF_embed(PGFObject* self, PyObject *args) PGF_embed(PGFObject* self, PyObject *args)
{ {
PgfCId modname; PgfCId modname;
if (!PyArg_ParseTuple(args, "s", &modname)) if (!PyArg_ParseTuple(args, "s", &modname))
return NULL; return NULL;
PyObject *m = PyImport_AddModule(modname); PyObject *m = PyImport_AddModule(modname);
if (m == NULL) if (m == NULL)
return NULL; return NULL;
GuPool* tmp_pool = gu_local_pool(); GuPool* tmp_pool = gu_local_pool();
@@ -3285,9 +3285,9 @@ static PyTypeObject pgf_PGFType = {
static PGFObject* static PGFObject*
pgf_readPGF(PyObject *self, PyObject *args) pgf_readPGF(PyObject *self, PyObject *args)
{ {
const char *fpath; const char *fpath;
if (!PyArg_ParseTuple(args, "s", &fpath)) if (!PyArg_ParseTuple(args, "s", &fpath))
return NULL; return NULL;
PGFObject* py_pgf = (PGFObject*) pgf_PGFType.tp_alloc(&pgf_PGFType, 0); PGFObject* py_pgf = (PGFObject*) pgf_PGFType.tp_alloc(&pgf_PGFType, 0);
py_pgf->pool = gu_new_pool(); py_pgf->pool = gu_new_pool();
@@ -3318,9 +3318,9 @@ pgf_readPGF(PyObject *self, PyObject *args)
static ExprObject* static ExprObject*
pgf_readExpr(PyObject *self, PyObject *args) { pgf_readExpr(PyObject *self, PyObject *args) {
Py_ssize_t len; Py_ssize_t len;
const uint8_t *buf; const uint8_t *buf;
if (!PyArg_ParseTuple(args, "s#", &buf, &len)) if (!PyArg_ParseTuple(args, "s#", &buf, &len))
return NULL; return NULL;
ExprObject* pyexpr = (ExprObject*) pgf_ExprType.tp_alloc(&pgf_ExprType, 0); ExprObject* pyexpr = (ExprObject*) pgf_ExprType.tp_alloc(&pgf_ExprType, 0);
if (pyexpr == NULL) if (pyexpr == NULL)
@@ -3348,9 +3348,9 @@ pgf_readExpr(PyObject *self, PyObject *args) {
static TypeObject* static TypeObject*
pgf_readType(PyObject *self, PyObject *args) { pgf_readType(PyObject *self, PyObject *args) {
Py_ssize_t len; Py_ssize_t len;
const uint8_t *buf; const uint8_t *buf;
if (!PyArg_ParseTuple(args, "s#", &buf, &len)) if (!PyArg_ParseTuple(args, "s#", &buf, &len))
return NULL; return NULL;
TypeObject* pytype = (TypeObject*) pgf_TypeType.tp_alloc(&pgf_TypeType, 0); TypeObject* pytype = (TypeObject*) pgf_TypeType.tp_alloc(&pgf_TypeType, 0);
if (pytype == NULL) if (pytype == NULL)
@@ -3405,20 +3405,20 @@ MOD_INIT(pgf)
{ {
PyObject *m; PyObject *m;
if (PyType_Ready(&pgf_PGFType) < 0) if (PyType_Ready(&pgf_PGFType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;
if (PyType_Ready(&pgf_ConcrType) < 0) if (PyType_Ready(&pgf_ConcrType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;
if (PyType_Ready(&pgf_BracketType) < 0) if (PyType_Ready(&pgf_BracketType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;
if (PyType_Ready(&pgf_ExprType) < 0) if (PyType_Ready(&pgf_ExprType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;
if (PyType_Ready(&pgf_TypeType) < 0) if (PyType_Ready(&pgf_TypeType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;
if (PyType_Ready(&pgf_IterType) < 0) if (PyType_Ready(&pgf_IterType) < 0)
return MOD_ERROR_VAL; return MOD_ERROR_VAL;