Index: test/python_api/import/TestImport.py
===================================================================
--- test/python_api/import/TestImport.py	(revision 0)
+++ test/python_api/import/TestImport.py	(revision 0)
@@ -0,0 +1,59 @@
+"""Test custom import command to import files by path."""
+
+import os, sys, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class ImportTestCase(TestBase):
+
+    mydir = os.path.join("python_api", "import")
+
+    @python_api_test
+    def test_import_command(self):
+        """Import some Python scripts by path and test them"""
+        self.run_test()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+
+    def run_test(self):
+        """Import some Python scripts by path and test them."""
+
+        # This is the function to remove the custom commands in order to have a
+        # clean slate for the next test case.
+        def cleanup():
+            self.runCmd('command script delete foo2cmd', check=False)
+            self.runCmd('command script delete foocmd', check=False)
+            self.runCmd('command script delete foobarcmd', check=False)
+            self.runCmd('command script delete barcmd', check=False)
+            self.runCmd('command script delete barothercmd', check=False)
+
+        # Execute the cleanup function during test case tear down.
+        self.addTearDownHook(cleanup)
+
+        self.runCmd("command script import ./foo/foo.py")
+        self.runCmd("command script import ./foo/foo2.py")
+        self.runCmd("command script import ./foo/bar/foobar.py")
+        self.runCmd("command script import ./bar/bar.py")
+        self.runCmd("command script add -f foo.foo_function foocmd")
+        self.runCmd("command script add -f foobar.foo_function foobarcmd")
+        self.runCmd("command script add -f bar.bar_function barcmd")
+        self.expect("foocmd hello",
+                substrs = ['foo says', 'hello'])
+        self.expect("foo2cmd hello",
+                substrs = ['foo2 says', 'hello'])
+        self.expect("barcmd hello",
+                substrs = ['barutil says', 'bar told me', 'hello'])
+        self.expect("barothercmd hello",
+                substrs = ['barutil says', 'bar told me', 'hello'])
+        self.expect("foobarcmd hello",
+                substrs = ['foobar says', 'hello'])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()
Index: test/python_api/import/foo/bar/foobar.py
===================================================================
--- test/python_api/import/foo/bar/foobar.py	(revision 0)
+++ test/python_api/import/foo/bar/foobar.py	(revision 0)
@@ -0,0 +1,3 @@
+def foo_function(debugger, args, result, dict):
+	result.Printf("foobar says " + args)
+	return None
Index: test/python_api/import/foo/foo.py
===================================================================
--- test/python_api/import/foo/foo.py	(revision 0)
+++ test/python_api/import/foo/foo.py	(revision 0)
@@ -0,0 +1,3 @@
+def foo_function(debugger, args, result, dict):
+	result.Printf("foo says " + args)
+	return None
Index: test/python_api/import/foo/foo2.py
===================================================================
--- test/python_api/import/foo/foo2.py	(revision 0)
+++ test/python_api/import/foo/foo2.py	(revision 0)
@@ -0,0 +1,7 @@
+def foo2_function(debugger, args, result, dict):
+	result.Printf("foo2 says " + args)
+	return None
+
+def __lldb_init_module(debugger, session_dict):
+	debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd")
+	return None
\ No newline at end of file
Index: test/python_api/import/bar/barutil.py
===================================================================
--- test/python_api/import/bar/barutil.py	(revision 0)
+++ test/python_api/import/bar/barutil.py	(revision 0)
@@ -0,0 +1,2 @@
+def barutil_function(x):
+	return "barutil says: " + x
Index: test/python_api/import/bar/bar.py
===================================================================
--- test/python_api/import/bar/bar.py	(revision 0)
+++ test/python_api/import/bar/bar.py	(revision 0)
@@ -0,0 +1,10 @@
+def bar_function(debugger, args, result, dict):
+	global UtilityModule
+	result.Printf(UtilityModule.barutil_function("bar told me " + args))
+	return None
+
+def __lldb_init_module(debugger, session_dict):
+	global UtilityModule
+	UtilityModule = __import__("barutil")
+	debugger.HandleCommand("command script add -f bar.bar_function barothercmd")
+	return None
\ No newline at end of file
Index: test/python_api/import/main.c
===================================================================
--- test/python_api/import/main.c	(revision 0)
+++ test/python_api/import/main.c	(revision 0)
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main(int argc, char const *argv[]) {
+    printf("Hello world.\n"); // Set break point at this line.
+    if (argc == 1)
+        return 0;
+
+    // Waiting to be attached by the debugger, otherwise.
+    char line[100];
+    while (fgets(line, sizeof(line), stdin)) { // Waiting to be attached...
+        printf("input line=>%s\n", line);
+    }
+
+    printf("Exiting now\n");
+}
Index: test/python_api/import/Makefile
===================================================================
--- test/python_api/import/Makefile	(revision 0)
+++ test/python_api/import/Makefile	(revision 0)
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+EXE := hello_world
+
+include $(LEVEL)/Makefile.rules
Index: include/lldb/Interpreter/ScriptInterpreterPython.h
===================================================================
--- include/lldb/Interpreter/ScriptInterpreterPython.h	(revision 141951)
+++ include/lldb/Interpreter/ScriptInterpreterPython.h	(working copy)
@@ -40,7 +40,7 @@
 
     bool
     ExecuteOneLineWithReturn (const char *in_string, 
-                              ScriptInterpreter::ReturnType return_type,
+                              ScriptInterpreter::ScriptReturnType return_type,
                               void *ret_value);
 
     bool
@@ -108,7 +108,10 @@
                               lldb::ValueObjectSP valobj);
     
     virtual std::string
-    GetDocumentationForItem(const char* item);
+    GetDocumentationForItem (const char* item);
+    
+    virtual bool
+    LoadScriptingModule (const char* filename);
 
     void
     CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options,
@@ -141,7 +144,8 @@
                            SWIGPythonGetIndexOfChildWithName python_swig_get_index_child,
                            SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
                            SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
-                           SWIGPythonCallCommand python_swig_call_command);
+                           SWIGPythonCallCommand python_swig_call_command,
+                           SWIGPythonCallModuleInit python_swig_call_mod_init);
 
 protected:
 
Index: include/lldb/Interpreter/ScriptInterpreter.h
===================================================================
--- include/lldb/Interpreter/ScriptInterpreter.h	(revision 141951)
+++ include/lldb/Interpreter/ScriptInterpreter.h	(working copy)
@@ -48,24 +48,28 @@
                                                                      const char* args,
                                                                      std::string& err_msg,
                                                                      lldb_private::CommandReturnObject& cmd_retobj);
+    
+    typedef bool           (*SWIGPythonCallModuleInit)              (const std::string python_module_name,
+                                                                     const char *session_dictionary_name,
+                                                                     lldb::DebuggerSP& debugger);
 
     typedef enum
     {
-        eCharPtr,
-        eBool,
-        eShortInt,
-        eShortIntUnsigned,
-        eInt,
-        eIntUnsigned,
-        eLongInt,
-        eLongIntUnsigned,
-        eLongLong,
-        eLongLongUnsigned,
-        eFloat,
-        eDouble,
-        eChar,
-        eCharStrOrNone
-    } ReturnType;
+        eScriptReturnTypeCharPtr,
+        eScriptReturnTypeBool,
+        eScriptReturnTypeShortInt,
+        eScriptReturnTypeShortIntUnsigned,
+        eScriptReturnTypeInt,
+        eScriptReturnTypeIntUnsigned,
+        eScriptReturnTypeLongInt,
+        eScriptReturnTypeLongIntUnsigned,
+        eScriptReturnTypeLongLong,
+        eScriptReturnTypeLongLongUnsigned,
+        eScriptReturnTypeFloat,
+        eScriptReturnTypeDouble,
+        eScriptReturnTypeChar,
+        eScriptReturnTypeCharStrOrNone
+    } ScriptReturnType;
 
 
     ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang);
@@ -79,7 +83,7 @@
     ExecuteInterpreterLoop () = 0;
 
     virtual bool
-    ExecuteOneLineWithReturn (const char *in_string, ReturnType return_type, void *ret_value)
+    ExecuteOneLineWithReturn (const char *in_string, ScriptReturnType return_type, void *ret_value)
     {
         return true;
     }
@@ -176,20 +180,26 @@
     }
         
     virtual bool
-    RunScriptBasedCommand(const char* impl_function,
-                          const char* args,
-                          lldb_private::CommandReturnObject& cmd_retobj,
-                          Error& error)
+    RunScriptBasedCommand (const char* impl_function,
+                           const char* args,
+                           lldb_private::CommandReturnObject& cmd_retobj,
+                           Error& error)
     {
         return false;
     }
     
     virtual std::string
-    GetDocumentationForItem(const char* item)
+    GetDocumentationForItem (const char* item)
     {
         return std::string("");
     }
 
+    virtual bool
+    LoadScriptingModule (const char* filename)
+    {
+        return false;
+    }
+
     const char *
     GetScriptInterpreterPtyName ();
 
@@ -212,7 +222,8 @@
                            SWIGPythonGetIndexOfChildWithName python_swig_get_index_child,
                            SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
                            SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
-                           SWIGPythonCallCommand python_swig_call_command);
+                           SWIGPythonCallCommand python_swig_call_command,
+                           SWIGPythonCallModuleInit python_swig_call_mod_init);
 
     static void
     TerminateInterpreter ();
Index: scripts/Python/python-wrapper.swig
===================================================================
--- scripts/Python/python-wrapper.swig	(revision 141951)
+++ scripts/Python/python-wrapper.swig	(working copy)
@@ -676,7 +676,89 @@
         PyErr_Print();
         PyErr_Clear ();
     }
-return retval;
+    return retval;
 }
 
+SWIGEXPORT bool
+LLDBSwigPythonCallModuleInit 
+(
+    const std::string python_module_name,
+    const char *session_dictionary_name,
+    lldb::DebuggerSP& debugger
+)
+{
+
+    lldb::SBDebugger debugger_sb(debugger);
+
+    bool retval = false;
+
+    PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0);
+
+    if (DebuggerObj_PyObj == NULL)
+        return retval;
+        
+    if (!(python_module_name.length()) || !session_dictionary_name)
+        return retval;
+
+    PyObject *session_dict, *pfunc;
+    PyObject *pargs, *pvalue;
+    
+    session_dict = FindSessionDictionary (session_dictionary_name);
+    
+    std::string python_function_name_string = python_module_name + (".__lldb_init_module");
+    const char* python_function_name = python_function_name_string.c_str();
+    
+    if (session_dict != NULL)
+    {
+        pfunc = ResolvePythonName (python_function_name, session_dict);
+        
+        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
+        {
+            PyErr_Clear();
+            return true;
+        }
+
+        if (pfunc == NULL)
+            return true;
+        else
+        {
+            // Set up the arguments and call the function.
+                
+            if (PyCallable_Check (pfunc))
+            {
+                pargs = PyTuple_New (2);
+                if (pargs == NULL)
+                {
+                    if (PyErr_Occurred())
+                        PyErr_Clear();
+                    return retval;
+                }
+                
+                PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj);  // This "steals" a reference to DebuggerObj_PyObj
+                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
+                pvalue = PyObject_CallObject (pfunc, pargs);
+                Py_DECREF (pargs);
+                
+                if (PyErr_Occurred ())
+                {
+                    PyErr_Print();
+                    PyErr_Clear();
+                }
+                else
+                {
+                    retval = true;
+                    Py_XDECREF (pvalue);
+                }
+                Py_INCREF (session_dict);
+            }
+            else if (PyErr_Occurred())
+            {
+                PyErr_Print();
+                PyErr_Clear();
+            }
+        }
+    }
+    return retval;
+}
+
 %}
Index: source/Commands/CommandObjectCommands.cpp
===================================================================
--- source/Commands/CommandObjectCommands.cpp	(revision 141951)
+++ source/Commands/CommandObjectCommands.cpp	(working copy)
@@ -1220,7 +1220,78 @@
     
 };
 
+//-------------------------------------------------------------------------
+// CommandObjectCommandsScriptImport
+//-------------------------------------------------------------------------
 
+class CommandObjectCommandsScriptImport : public CommandObject
+{
+public:
+    CommandObjectCommandsScriptImport (CommandInterpreter &interpreter) :
+    CommandObject (interpreter,
+                   "command script import",
+                   "Import a scripting module in LLDB.",
+                   NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentData cmd_arg;
+        
+        // Define the first (and only) variant of this arg.
+        cmd_arg.arg_type = eArgTypePath;
+        cmd_arg.arg_repetition = eArgRepeatPlain;
+        
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (cmd_arg);
+        
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+    }
+    
+    ~CommandObjectCommandsScriptImport ()
+    {
+    }
+    
+    bool
+    Execute
+    (
+     Args& args,
+     CommandReturnObject &result
+     )
+    {
+        
+        if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
+        {
+            result.AppendError ("only scripting language supported for module importing is currently Python");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+        
+        size_t argc = args.GetArgumentCount();
+        
+        if (argc != 1)
+        {
+            result.AppendError ("'command script import' requires one argument");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+        
+        std::string path = args.GetArgumentAtIndex(0);
+        
+        if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str()))
+        {
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            result.AppendError("cannot import module");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        
+        return result.Succeeded();
+        
+    }
+};
+
 //-------------------------------------------------------------------------
 // CommandObjectCommandsScriptAdd
 //-------------------------------------------------------------------------
@@ -1684,6 +1755,7 @@
         LoadSubCommand ("delete",   CommandObjectSP (new CommandObjectCommandsScriptDelete (interpreter)));
         LoadSubCommand ("clear", CommandObjectSP (new CommandObjectCommandsScriptClear (interpreter)));
         LoadSubCommand ("list",   CommandObjectSP (new CommandObjectCommandsScriptList (interpreter)));
+        LoadSubCommand ("import",   CommandObjectSP (new CommandObjectCommandsScriptImport (interpreter)));
     }
 
     ~CommandObjectMultiwordCommandsScript ()
Index: source/Interpreter/ScriptInterpreter.cpp
===================================================================
--- source/Interpreter/ScriptInterpreter.cpp	(revision 141951)
+++ source/Interpreter/ScriptInterpreter.cpp	(working copy)
@@ -100,7 +100,8 @@
                                           SWIGPythonGetIndexOfChildWithName python_swig_get_index_child,
                                           SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
                                           SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
-                                          SWIGPythonCallCommand python_swig_call_command)
+                                          SWIGPythonCallCommand python_swig_call_command,
+                                          SWIGPythonCallModuleInit python_swig_call_mod_init)
 {
     ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback, 
                                                     python_swig_breakpoint_callback,
@@ -111,7 +112,8 @@
                                                     python_swig_get_index_child,
                                                     python_swig_cast_to_sbvalue,
                                                     python_swig_update_provider,
-                                                    python_swig_call_command);
+                                                    python_swig_call_command,
+                                                    python_swig_call_mod_init);
 }
 
 void
Index: source/Interpreter/ScriptInterpreterPython.cpp
===================================================================
--- source/Interpreter/ScriptInterpreterPython.cpp	(revision 141951)
+++ source/Interpreter/ScriptInterpreterPython.cpp	(working copy)
@@ -42,6 +42,7 @@
 static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue  = NULL;
 static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = NULL;
 static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = NULL;
+static ScriptInterpreter::SWIGPythonCallModuleInit g_swig_call_module_init = NULL;
 
 static int
 _check_and_flush (FILE *stream)
@@ -199,6 +200,10 @@
     PyRun_SimpleString (run_string.GetData());
 
     run_string.Clear();
+    run_string.Printf ("run_one_line (%s, 'import os')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    
+    run_string.Clear();
     run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %d')", m_dictionary_name.c_str(),
                        interpreter.GetDebugger().GetID());
     PyRun_SimpleString (run_string.GetData());
@@ -702,7 +707,7 @@
 
 bool
 ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
-                                                   ScriptInterpreter::ReturnType return_type,
+                                                   ScriptInterpreter::ScriptReturnType return_type,
                                                    void *ret_value)
 {
 
@@ -783,85 +788,85 @@
         {
             switch (return_type)
             {
-                case eCharPtr: // "char *"
+                case eScriptReturnTypeCharPtr: // "char *"
                 {
                     const char format[3] = "s#";
                     success = PyArg_Parse (py_return, format, (char **) ret_value);
                     break;
                 }
-                case eCharStrOrNone: // char* or NULL if py_return == Py_None
+                case eScriptReturnTypeCharStrOrNone: // char* or NULL if py_return == Py_None
                 {
                     const char format[3] = "z";
                     success = PyArg_Parse (py_return, format, (char **) ret_value);
                     break;
                 }
-                case eBool:
+                case eScriptReturnTypeBool:
                 {
                     const char format[2] = "b";
                     success = PyArg_Parse (py_return, format, (bool *) ret_value);
                     break;
                 }
-                case eShortInt:
+                case eScriptReturnTypeShortInt:
                 {
                     const char format[2] = "h";
                     success = PyArg_Parse (py_return, format, (short *) ret_value);
                     break;
                 }
-                case eShortIntUnsigned:
+                case eScriptReturnTypeShortIntUnsigned:
                 {
                     const char format[2] = "H";
                     success = PyArg_Parse (py_return, format, (unsigned short *) ret_value);
                     break;
                 }
-                case eInt:
+                case eScriptReturnTypeInt:
                 {
                     const char format[2] = "i";
                     success = PyArg_Parse (py_return, format, (int *) ret_value);
                     break;
                 }
-                case eIntUnsigned:
+                case eScriptReturnTypeIntUnsigned:
                 {
                     const char format[2] = "I";
                     success = PyArg_Parse (py_return, format, (unsigned int *) ret_value);
                     break;
                 }
-                case eLongInt:
+                case eScriptReturnTypeLongInt:
                 {
                     const char format[2] = "l";
                     success = PyArg_Parse (py_return, format, (long *) ret_value);
                     break;
                 }
-                case eLongIntUnsigned:
+                case eScriptReturnTypeLongIntUnsigned:
                 {
                     const char format[2] = "k";
                     success = PyArg_Parse (py_return, format, (unsigned long *) ret_value);
                     break;
                 }
-                case eLongLong:
+                case eScriptReturnTypeLongLong:
                 {
                     const char format[2] = "L";
                     success = PyArg_Parse (py_return, format, (long long *) ret_value);
                     break;
                 }
-                case eLongLongUnsigned:
+                case eScriptReturnTypeLongLongUnsigned:
                 {
                     const char format[2] = "K";
                     success = PyArg_Parse (py_return, format, (unsigned long long *) ret_value);
                     break;
                 }
-                case eFloat:
+                case eScriptReturnTypeFloat:
                 {
                     const char format[2] = "f";
                     success = PyArg_Parse (py_return, format, (float *) ret_value);
                     break;
                 }
-                case eDouble:
+                case eScriptReturnTypeDouble:
                 {
                     const char format[2] = "d";
                     success = PyArg_Parse (py_return, format, (double *) ret_value);
                     break;
                 }
-                case eChar:
+                case eScriptReturnTypeChar:
                 {
                     const char format[2] = "c";
                     success = PyArg_Parse (py_return, format, (char *) ret_value);
@@ -1824,7 +1829,145 @@
     return;
 }
 
+static char* strrstr (const char *haystack, const char *needle)
+{
+	char *r = NULL;
+    
+    if (!haystack)
+        return NULL;
+    
+	if (!needle || !needle[0])
+		return NULL;
+    
+	while (1) {
+		char *p = strstr(haystack, needle);
+		if (!p)
+			return r;
+		r = p;
+		haystack = p + 1;
+	}
+}
+
+static bool
+SplitPathInDirAndFile (const char* path,
+                       std::string* dir,
+                       std::string* file,
+                       const char* sep)
+{
+    
+    if (!path || !path[0] || !dir || !file || !sep || !sep[0])
+        return false;
+    
+    if (::strstr(path, sep) == NULL) // plain file name "foo.bar"
+    {
+        *dir = std::string(".");
+        *file = std::string(path);
+    }
+    else // full pathname "/etc/init.d/foo.bar"
+    {
+        const char* last_sep = strrstr(path, sep);
+        *file = std::string(last_sep+strlen(sep));
+        *dir = std::string(path,last_sep-path);
+    }
+    return true;
+}
+
 bool
+ScriptInterpreterPython::LoadScriptingModule (const char* pathname)
+{
+    if (!pathname)
+        return false;
+    
+    if (!pathname[0])
+        return false;
+    
+    if (!g_swig_call_module_init)
+        return false;
+    
+    ScriptInterpreterPython *python_interpreter = this;
+    
+    lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP();
+    
+    static char* os_sep = NULL;
+    
+    FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout);
+    
+    {
+        Locker py_lock(python_interpreter, tmp_fh);
+        
+        // we use Python's portable mechanism (os.sep) to detect the path separator
+        // it looks like there is no obvious alternative in pure C++
+        if (!os_sep)
+        {
+            char* os_sep_ptr = NULL;
+            if (!python_interpreter->ExecuteOneLineWithReturn("os.sep",
+                                                              ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
+                                                              &os_sep_ptr) ||
+                !os_sep_ptr)
+                return false;
+            
+            // make a permanent copy of the separator
+            size_t sep_len = strlen(os_sep_ptr);
+            os_sep = new char[sep_len+1]; os_sep[sep_len] = '\0';
+            memcpy(os_sep, os_sep_ptr, sep_len);
+        }
+        
+        // expand pathname given (it may include special symbols like ~, we want an absolute path)
+        // and also split it into directory and filename
+        std::string directory,basename;
+        SplitPathInDirAndFile(pathname, &directory, &basename, os_sep);
+        char* exp_directory_ptr = NULL;
+        directory = std::string("os.path.abspath(os.path.expanduser('") + directory + std::string("'))");
+        if (!python_interpreter->ExecuteOneLineWithReturn(directory.c_str(),
+                                                          ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
+                                                          &exp_directory_ptr) || 
+            !exp_directory_ptr)
+            return false;
+        directory = std::string(exp_directory_ptr);
+        
+        // now make sure that Python has "directory" in the search path
+        std::string command("if not (sys.path.__contains__('" + directory + "')):\n    sys.path.append('" + directory + "');\n\n");
+        python_interpreter->ExecuteMultipleLines(command.c_str());
+        
+        // because this is a filename, it will probably end with .py or .pyc
+        std::string::reverse_iterator rbeg = basename.rbegin();
+        bool has_dotpy = false;
+        bool has_dotpyc = false;
+        if(*rbeg == 'c') // ends with c
+        {
+            rbeg++; // might be .pyc, let's check
+            has_dotpyc = true;
+        }
+        if (*rbeg == 'y') // either ends with .py or has a final yc
+        {
+            if (*(++rbeg) == 'p')
+            {
+                if (*(++rbeg) == '.')
+                    has_dotpy = true;
+            }
+        }
+        if (has_dotpy) // has a final extension that we care to strip
+        {
+            if (has_dotpyc) // if pyc..
+                basename.resize(basename.length()-4);
+            else // if py
+                basename.resize(basename.length()-3);
+        }
+        
+        // now actually do the import
+        command = std::string("import ") + basename;
+        bool import_retval = python_interpreter->ExecuteOneLine(command.c_str(), NULL);
+        if (!import_retval)
+            return false;
+        
+        // call __lldb_module_init(debugger,dict)
+        return g_swig_call_module_init (basename,
+                                        python_interpreter->m_dictionary_name.c_str(),
+                                        debugger_sp);
+    }
+}
+
+bool
 ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
                                                const char* args,
                                                lldb_private::CommandReturnObject& cmd_retobj,
@@ -1886,7 +2029,7 @@
     char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully
     
     if (ExecuteOneLineWithReturn (command.c_str(),
-                                 ScriptInterpreter::eCharStrOrNone,
+                                 ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
                                  &result_ptr) && result_ptr)
     {
         return std::string(result_ptr);
@@ -1905,7 +2048,8 @@
                                                 SWIGPythonGetIndexOfChildWithName python_swig_get_index_child,
                                                 SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
                                                 SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
-                                                SWIGPythonCallCommand python_swig_call_command)
+                                                SWIGPythonCallCommand python_swig_call_command,
+                                                SWIGPythonCallModuleInit python_swig_call_mod_init)
 {
     g_swig_init_callback = python_swig_init_callback;
     g_swig_breakpoint_callback = python_swig_breakpoint_callback;
@@ -1917,6 +2061,7 @@
     g_swig_cast_to_sbvalue = python_swig_cast_to_sbvalue;
     g_swig_update_provider = python_swig_update_provider;
     g_swig_call_command = python_swig_call_command;
+    g_swig_call_module_init = python_swig_call_mod_init;
 }
 
 void
Index: source/API/SBCommandInterpreter.cpp
===================================================================
--- source/API/SBCommandInterpreter.cpp	(revision 141951)
+++ source/API/SBCommandInterpreter.cpp	(working copy)
@@ -358,7 +358,14 @@
     lldb_private::CommandReturnObject& cmd_retobj
 );
 
+extern "C" bool           LLDBSwigPythonCallModuleInit 
+(
+    const std::string python_module_name,
+    const char *session_dictionary_name,
+    lldb::DebuggerSP& debugger
+);
 
+
 extern "C" void init_lldb(void);
 
 void
@@ -377,6 +384,7 @@
                                                   LLDBSwigPython_GetIndexOfChildWithName,
                                                   LLDBSWIGPython_CastPyObjectToSBValue,
                                                   LLDBSwigPython_UpdateSynthProviderInstance,
-                                                  LLDBSwigPythonCallCommand);
+                                                  LLDBSwigPythonCallCommand,
+                                                  LLDBSwigPythonCallModuleInit);
     }
 }
