mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Modified PyImport_Import and PyImport_ImportModule to always use absolute imports by calling __import__ with an explicit level of 0
Added a new API function PyImport_ImportModuleNoBlock. It solves the problem with dead locks when mixing threads and imports
This commit is contained in:
parent
0a83d79268
commit
000a074c95
19 changed files with 135 additions and 63 deletions
|
@ -14,13 +14,10 @@ PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
|
|||
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name,
|
||||
PyObject *globals, PyObject *locals, PyObject *fromlist, int level);
|
||||
|
||||
/* For DLL compatibility */
|
||||
#undef PyImport_ImportModuleEx
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleEx(
|
||||
char *name, PyObject *globals, PyObject *locals, PyObject *fromlist);
|
||||
#define PyImport_ImportModuleEx(n, g, l, f) \
|
||||
PyImport_ImportModuleLevel(n, g, l, f, -1)
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static void **PyCurses_API;
|
|||
|
||||
#define import_curses() \
|
||||
{ \
|
||||
PyObject *module = PyImport_ImportModule("_curses"); \
|
||||
PyObject *module = PyImport_ImportModuleNoBlock("_curses"); \
|
||||
if (module != NULL) { \
|
||||
PyObject *module_dict = PyModule_GetDict(module); \
|
||||
PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue