From 93fe3d72360d5d565f8862139a8891d2872ea22e Mon Sep 17 00:00:00 2001 From: Moshe Zadka Date: Fri, 30 Mar 2001 19:45:13 +0000 Subject: [PATCH] - Importing should now be safe with multiple Py_Initialize/Py_Finalize sequences. --- Misc/NEWS | 3 +++ Python/import.c | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 25638538893b..262d87ef8f90 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -45,6 +45,9 @@ http://sourceforge.net/tracker/index.php?func=detail&aid=&group_id=5470&atid - Fixed memory leak in from import ... +- Importing should now be safe with multiple Py_Initialize/Py_Finalize + sequences. + What's New in Python 2.0? ========================= diff --git a/Python/import.c b/Python/import.c index 8d06a53adf83..203fe41051f7 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1842,7 +1842,6 @@ PyImport_Import(PyObject *module_name) static PyObject *silly_list = NULL; static PyObject *builtins_str = NULL; static PyObject *import_str = NULL; - static PyObject *standard_builtins = NULL; PyObject *globals = NULL; PyObject *import = NULL; PyObject *builtins = NULL; @@ -1873,15 +1872,10 @@ PyImport_Import(PyObject *module_name) /* No globals -- use standard builtins, and fake globals */ PyErr_Clear(); - if (standard_builtins == NULL) { - standard_builtins = - PyImport_ImportModule("__builtin__"); - if (standard_builtins == NULL) - return NULL; - } - - builtins = standard_builtins; - Py_INCREF(builtins); + builtins = PyImport_ImportModuleEx("__builtin__", + NULL, NULL, NULL); + if (builtins == NULL) + return NULL; globals = Py_BuildValue("{OO}", builtins_str, builtins); if (globals == NULL) goto err; -- 2.47.3