Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix module load problem of cPickle in case of multithreading. Patch by
Guoqiang Zhang.
8 changes: 8 additions & 0 deletions Modules/cPickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3365,7 +3365,15 @@ find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc)
if (module == NULL)
return NULL;

_PyImport_AcquireLock();
module = PyDict_GetItem(module, py_module_name);
if (_PyImport_ReleaseLock() < 0) {
Py_XDECREF(module);
PyErr_SetString(PyExc_RuntimeError,
"not holding the import lock");
return NULL;
}

if (module == NULL) {
module = PyImport_Import(py_module_name);
if (!module)
Expand Down