From 33f7c9859096747d0a6ac16849e3e9d274d43dc3 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 17 Dec 2009 11:57:56 +0000 Subject: [PATCH] Fix a problem of RTTI data initialization in the libraries loaded by Python (SWIG-modules, etc). Additional fix: dl module can be unavaiable in Python. --- src/KERNEL_PY/salome.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/KERNEL_PY/salome.py b/src/KERNEL_PY/salome.py index 9f7b0b1f7..f6afea4d1 100755 --- a/src/KERNEL_PY/salome.py +++ b/src/KERNEL_PY/salome.py @@ -85,8 +85,43 @@ variables: from salome_kernel import * from salome_study import * from salome_iapp import * -import dl, sys -sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) + + +# +# The next block is workaround for the problem of shared symbols loading for the extension modules (e.g. SWIG-generated) +# that causes RTTI unavailable in some cases. To solve this problem, sys.setdlopenflags() function is used. +# Depending on the Python version and platform, the dlopen flags can be defined in the dl, DLFUN or ctypes module. +# +import sys +flags = None +if not flags: + try: + # dl module can be unavailable + import dl + flags = dl.RTLD_NOW | dl.RTLD_GLOBAL + except: + pass + pass +if not flags: + try: + # DLFCN module can be unavailable + import DLFCN + flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL + except: + pass + pass +if not flags: + try: + # ctypes module can be unavailable + import ctypes + flags = ctypes.RTLD_GLOBAL + except: + pass + pass + +if flags: + sys.setdlopenflags(flags) + pass orb, lcc, naming_service, cm,sg=None,None,None,None,None myStudyManager, myStudyId, myStudy, myStudyName=None,None,None,None -- 2.39.2