]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Initialize per-query qdata and per-module mod_env 4/head
authorPhilipp Serr <episource@gmx.de>
Sat, 21 Jan 2017 14:47:54 +0000 (15:47 +0100)
committerPhilipp Serr <episource@gmx.de>
Sat, 2 Mar 2019 08:26:57 +0000 (09:26 +0100)
The python module used to assign None to the per-query (qdata argument)
and per-module (mod_env variable) data stores. Hence, there was no
obvious way for python code to use these data stores.

This commit initializes both data stores with a dict instance.

pythonmod/pythonmod.c

index a668ecc23cc70da904078e116dc6198315f3e3fb..02908af565f21ae17696d6cd97237c909bffed3c 100644 (file)
@@ -317,8 +317,7 @@ int pythonmod_init(struct module_env* env, int id)
    /* Load file */
    pe->module = PyImport_AddModule("__main__");
    pe->dict = PyModule_GetDict(pe->module);
-   pe->data = Py_None;
-   Py_INCREF(pe->data);
+   pe->data = PyDict_New();
    PyModule_AddObject(pe->module, "mod_env", pe->data);
 
    /* TODO: deallocation of pe->... if an error occurs */
@@ -485,8 +484,7 @@ void pythonmod_operate(struct module_qstate* qstate, enum module_ev event,
       pq = qstate->minfo[id] = malloc(sizeof(struct pythonmod_qstate));
 
       /* Initialize per query data */
-      pq->data = Py_None;
-      Py_INCREF(pq->data);
+      pq->data = PyDict_New();
    }
 
    /* Call operate */