Initialize per-query qdata and per-module mod_env

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.
This commit is contained in:
Philipp Serr 2017-01-21 15:47:54 +01:00
parent dfe8e0dfa2
commit 7cc4ff05ad

View 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 */