diff options
| author | aneejit1 <aneejit1@gmail.com> | 2022-04-19 00:17:45 +0000 |
|---|---|---|
| committer | Slávek Banko <slavek.banko@axis.cz> | 2022-04-21 17:35:12 +0200 |
| commit | 5e00e331b79ece72843aa62af1a79090d0997a0e (patch) | |
| tree | c86eeb36924a75499d53d58417833b1f915eb6fe /siplib/siplib.c | |
| parent | db6ca2190e3e95ccd28b99e2b981cc8f16ccd628 (diff) | |
| download | sip4-tqt-5e00e331b79ece72843aa62af1a79090d0997a0e.tar.gz sip4-tqt-5e00e331b79ece72843aa62af1a79090d0997a0e.zip | |
Updates for Python 3 Supportr14.0.12
The following changes have been made to support Python 3:
- in sip-tqt.h, remove the cast in the "sipConvertFromSliceObject"
macro in versions 3.2+ as the API changed causing a compile error;
- in voidptr.h, alter the precompile conditions to remove the
PyCObject API cals for version 3.2+ (causes runtime symbol
resolution error) and amend the flags for "asstring";
- alter module import process in siplib.c to avoid re-loading an
already loaded module.
Signed-off-by: aneejit1 <aneejit1@gmail.com>
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 5b12d262dc940b6fe9e2766988917665c970318d)
Diffstat (limited to 'siplib/siplib.c')
| -rw-r--r-- | siplib/siplib.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/siplib/siplib.c b/siplib/siplib.c index d43f121..ebbc194 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. |
