Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2293:3789df86dd71
Date: 2015-09-30 16:57 +0200
http://bitbucket.org/cffi/cffi/changeset/3789df86dd71/
Log: Maybe a fix for multiple interpreters
diff --git a/c/cffi1_module.c b/c/cffi1_module.c
--- a/c/cffi1_module.c
+++ b/c/cffi1_module.c
@@ -21,33 +21,38 @@
{
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;
- Py_DECREF(x);
+ 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;
+
+ 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;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit