[Lldb-commits] [lldb] r237282 - Fix an issue with finding python on Windows.

Zachary Turner zturner at google.com
Wed May 13 12:44:58 PDT 2015


Author: zturner
Date: Wed May 13 14:44:57 2015
New Revision: 237282

URL: http://llvm.org/viewvc/llvm-project?rev=237282&view=rev
Log:
Fix an issue with finding python on Windows.

Someone must have changed the behavior of FileSpec slightly
relating to whether or not there is a trailing backslash when calling
GetPath() and GetDirectory().  This caused ScriptInterpreterPython
to find the wrong values when initializing sys.path, and as a result
we couldn't find the lldb module.

This patch fixes the issue, and also adds a test to make sure that
GetDirectory() does not return a string containing a trailing slash.

Modified:
    lldb/trunk/source/Host/windows/HostInfoWindows.cpp
    lldb/trunk/test/functionalities/paths/TestPaths.py

Modified: lldb/trunk/source/Host/windows/HostInfoWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostInfoWindows.cpp?rev=237282&r1=237281&r2=237282&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/HostInfoWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/HostInfoWindows.cpp Wed May 13 14:44:57 2015
@@ -109,8 +109,7 @@ HostInfoWindows::ComputePythonDirectory(
     FileSpec lldb_file_spec;
     if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
         return false;
-    llvm::SmallString<64> path;
-    lldb_file_spec.GetPath(path);
+    llvm::SmallString<64> path(lldb_file_spec.GetDirectory().AsCString());
     llvm::sys::path::remove_filename(path);
     llvm::sys::path::append(path, "lib", "site-packages");
     std::replace(path.begin(), path.end(), '\\', '/');

Modified: lldb/trunk/test/functionalities/paths/TestPaths.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/paths/TestPaths.py?rev=237282&r1=237281&r2=237282&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/paths/TestPaths.py (original)
+++ lldb/trunk/test/functionalities/paths/TestPaths.py Wed May 13 14:44:57 2015
@@ -34,6 +34,12 @@ class TestPaths(TestBase):
         # file path if it doesn't exist in the current directory.
         self.assertTrue (file_only.GetDirectory() == None)
 
+    def test_directory_doesnt_end_with_slash(self):
+        current_directory_spec = lldb.SBFileSpec(os.path.curdir)
+        current_directory_string = current_directory_spec.GetDirectory()
+        self.assertNotEqual(current_directory_string[-1:], '/')
+        pass
+
     @skipUnlessPlatform(["windows"])
     def test_windows_double_slash (self):
         '''Test to check the path with double slash is handled correctly '''





More information about the lldb-commits mailing list