Commit 0766f97f authored by Stefan Behnel's avatar Stefan Behnel

avoid risk of stale pointers by looking up Cython types module on each request...

avoid risk of stale pointers by looking up Cython types module on each request (shouldn't hurt much to do it a couple of times during module initialisation)
parent b722d04f
......@@ -5,13 +5,13 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
/////////////// FetchCommonType ///////////////
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
static PyObject* fake_module = NULL;
PyObject* fake_module;
PyTypeObject* cached_type = NULL;
const char* cython_module = "_cython_" CYTHON_ABI;
if (!fake_module) {
fake_module = PyImport_AddModule(cython_module);
if (!fake_module) goto bad;
}
fake_module = PyImport_AddModule(cython_module);
if (!fake_module) return NULL;
Py_INCREF(fake_module);
cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
if (!cached_type) {
......@@ -25,6 +25,7 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
}
bad:
Py_DECREF(fake_module);
// NOTE: always returns owned reference, or NULL on error
return cached_type;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment