From 6f04f47c8f973a5c8ab3647e62dc19979d3ec1ba Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 22 Oct 2019 12:34:48 +0100 Subject: [PATCH] key.c: Make `None' be the default report-function designator. Now we can pass it in from Python as an explicit argument. --- key.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/key.c b/key.c index d820cfa..50c5321 100644 --- a/key.c +++ b/key.c @@ -1619,7 +1619,7 @@ static void pythonreporter(const char *file, int line, if (ri->stop) return; - if (!ri->func) + if (ri->func == Py_None) key_moan(file, line, msg, 0); else if ((res = PyObject_CallFunction(ri->func, "sis", file, line, msg)) == 0) @@ -1631,7 +1631,7 @@ static void pythonreporter(const char *file, int line, static PyObject *keyfile_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { - struct reportinfo ri = { 0, 0 }; + struct reportinfo ri = { Py_None, 0 }; char *file = 0; unsigned how = KOPEN_READ; keyfile_pyobj *rc = 0; @@ -1641,7 +1641,7 @@ static PyObject *keyfile_pynew(PyTypeObject *ty, if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|iO:new", KWLIST, &file, &how, &ri.func)) goto end; - if (ri.func && !PyCallable_Check(ri.func)) + if (ri.func != Py_None && !PyCallable_Check(ri.func)) TYERR("reporter function not callable"); if ((rc = (keyfile_pyobj *)ty->tp_alloc(ty, 0)) == 0) goto end; @@ -1688,7 +1688,7 @@ end: static PyObject *kfmeth_merge(PyObject *me, PyObject *arg, PyObject *kw) { - struct reportinfo ri = { 0, 0 }; + struct reportinfo ri = { Py_None, 0 }; char *name; PyObject *x = 0; FILE *fp = 0; @@ -1699,7 +1699,7 @@ static PyObject *kfmeth_merge(PyObject *me, PyObject *arg, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O:merge", KWLIST, &PyFile_Type, &x, &ri.func)) goto end; - if (ri.func && !PyCallable_Check(ri.func)) + if (ri.func != Py_None && !PyCallable_Check(ri.func)) TYERR("reporter function not callable"); if ((fp = PyFile_AsFile(x)) == 0) goto end; -- 2.11.0