summaryrefslogtreecommitdiffstats
path: root/siplib/siplib.c
diff options
context:
space:
mode:
Diffstat (limited to 'siplib/siplib.c')
-rw-r--r--siplib/siplib.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/siplib/siplib.c b/siplib/siplib.c
index e799280..fff9457 100644
--- a/siplib/siplib.c
+++ b/siplib/siplib.c
@@ -648,6 +648,8 @@ static int add_all_lazy_attrs(sipTypeDef *td);
static int objectify(const char *s, PyObject **objp);
static void add_failure(PyObject **parseErrp, sipParseFailure *failure);
static PyObject *bad_type_str(int arg_nr, PyObject *arg);
+static sipExportedModuleDef *isModuleLoaded(sipExportedModuleDef *table,
+ char *name);
/*
@@ -1200,12 +1202,14 @@ static int sip_api_export_module(sipExportedModuleDef *client,
{
PyObject *mod;
- if ((mod = PyImport_ImportModule(im->im_name)) == NULL)
- return -1;
+ em = isModuleLoaded(moduleList, im->im_name);
- for (em = moduleList; em != NULL; em = em->em_next)
- if (strcmp(sipNameOfModule(em), im->im_name) == 0)
- break;
+ if (em == NULL)
+ {
+ if ((mod = PyImport_ImportModule(im->im_name)) == NULL)
+ return -1;
+ em = isModuleLoaded(moduleList, im->im_name);
+ }
if (em == NULL)
{
@@ -1277,6 +1281,22 @@ static int sip_api_export_module(sipExportedModuleDef *client,
/*
+ * Find out if a client module has been loaded already.
+ */
+static sipExportedModuleDef *isModuleLoaded(sipExportedModuleDef *table,
+ char *name)
+{
+ sipExportedModuleDef *em = table;
+
+ for (em = moduleList; em != NULL; em = em->em_next)
+ if (strcmp(sipNameOfModule(em), name) == 0)
+ return em;
+
+ return NULL;
+}
+
+
+/*
* Initialise the contents of a client module. By this time anything that
* this depends on should have been initialised. A negative value is returned
* and an exception raised if there was an error.