summaryrefslogtreecommitdiff
path: root/c/cffi1_module.c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2015-09-30 16:57:25 +0200
committerArmin Rigo <arigo@tunes.org>2015-09-30 16:57:25 +0200
commit423ef8401ae065335dc0878eb0802873648bb058 (patch)
tree9526aad9d9366e8f253450c3b350f30f0c8d840b /c/cffi1_module.c
parentb356c68b0c383fd11c6927331ba1312afeb2eb42 (diff)
downloadcffi-423ef8401ae065335dc0878eb0802873648bb058.tar.gz
Maybe a fix for multiple interpreters
Diffstat (limited to 'c/cffi1_module.c')
-rw-r--r--c/cffi1_module.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/c/cffi1_module.c b/c/cffi1_module.c
index ac96a72..f79237b 100644
--- a/c/cffi1_module.c
+++ b/c/cffi1_module.c
@@ -21,33 +21,38 @@ static int init_ffi_lib(PyObject *m)
{
PyObject *x;
int i;
+ static int init_done = 0;
if (PyType_Ready(&FFI_Type) < 0)
return -1;
if (PyType_Ready(&Lib_Type) < 0)
return -1;
- if (init_global_types_dict(FFI_Type.tp_dict) < 0)
- return -1;
- FFIError = PyErr_NewException("ffi.error", NULL, NULL);
- if (FFIError == NULL)
- return -1;
- if (PyDict_SetItemString(FFI_Type.tp_dict, "error", FFIError) < 0)
- return -1;
- if (PyDict_SetItemString(FFI_Type.tp_dict, "CType",
- (PyObject *)&CTypeDescr_Type) < 0)
- return -1;
- if (PyDict_SetItemString(FFI_Type.tp_dict, "CData",
- (PyObject *)&CData_Type) < 0)
- return -1;
+ if (!init_done) {
+ if (init_global_types_dict(FFI_Type.tp_dict) < 0)
+ return -1;
- for (i = 0; all_dlopen_flags[i].name != NULL; i++) {
- x = PyInt_FromLong(all_dlopen_flags[i].value);
- if (x == NULL || PyDict_SetItemString(FFI_Type.tp_dict,
- all_dlopen_flags[i].name,
- x) < 0)
+ FFIError = PyErr_NewException("ffi.error", NULL, NULL);
+ if (FFIError == NULL)
+ return -1;
+ if (PyDict_SetItemString(FFI_Type.tp_dict, "error", FFIError) < 0)
+ return -1;
+ if (PyDict_SetItemString(FFI_Type.tp_dict, "CType",
+ (PyObject *)&CTypeDescr_Type) < 0)
return -1;
- Py_DECREF(x);
+ if (PyDict_SetItemString(FFI_Type.tp_dict, "CData",
+ (PyObject *)&CData_Type) < 0)
+ return -1;
+
+ for (i = 0; all_dlopen_flags[i].name != NULL; i++) {
+ x = PyInt_FromLong(all_dlopen_flags[i].value);
+ if (x == NULL || PyDict_SetItemString(FFI_Type.tp_dict,
+ all_dlopen_flags[i].name,
+ x) < 0)
+ return -1;
+ Py_DECREF(x);
+ }
+ init_done = 1;
}
x = (PyObject *)&FFI_Type;