[Lldb-commits] [lldb] r305461 - [swig] Improve the native module import logic
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 15 04:23:23 PDT 2017
Author: labath
Date: Thu Jun 15 06:23:22 2017
New Revision: 305461
URL: http://llvm.org/viewvc/llvm-project?rev=305461&view=rev
Log:
[swig] Improve the native module import logic
The simple module import logic was not sufficient for our distribution
model of lldb, which is without the _lldb.pyd file (normally that would
be a symlink to the shared library, but symlinks are not really a thing
on windows).
With the older swigs it worked (loading of the python scripting
machinery from within lldb) because the normal swig import logic
contained a last-ditch import of a global module _lldb (which is defined
when you run python from lldb). Add back the last-ditch import to our
custom import logic as well.
Modified:
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=305461&r1=305460&r2=305461&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Thu Jun 15 06:23:22 2017
@@ -40,7 +40,13 @@ us to override the module import logic t
Older swig versions will simply ignore this setting.
*/
%define MODULEIMPORT
-"from . import $module"
+"try:
+ # Try a relative import first
+ from . import $module
+except ImportError:
+ # Maybe absolute import will work (if we're being loaded from lldb, it
+ # should).
+ import $module"
%enddef
// These versions will not generate working python modules, so error out early.
#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011
More information about the lldb-commits
mailing list