[Libreoffice-commits] core.git: pyuno/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 19 19:14:55 UTC 2020


 pyuno/source/loader/pyuno_loader.cxx |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 327153471ae38abe90463f6272e00aaa996c5ba3
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jun 19 11:32:00 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jun 19 21:14:16 2020 +0200

    tdf#121384 don't leave a bare trailing : in PYTHONPATH
    
    and don't insert any empty path entries if that situation
    was to arise
    
    Change-Id: I8d8183485f457c3e4385181fee07390c4bfef603
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96713
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index 8556dfdde11f..07dc748235f9 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -140,6 +140,7 @@ static void setPythonHome ( const OUString & pythonHome )
 static void prependPythonPath( const OUString & pythonPathBootstrap )
 {
     OUStringBuffer bufPYTHONPATH( 256 );
+    bool bAppendSep = false;
     sal_Int32 nIndex = 0;
     while( true )
     {
@@ -155,15 +156,24 @@ static void prependPythonPath( const OUString & pythonPathBootstrap )
         }
         OUString systemPath;
         osl_getSystemPathFromFileURL( fileUrl.pData, &(systemPath.pData) );
-        bufPYTHONPATH.append( systemPath );
-        bufPYTHONPATH.append( static_cast<sal_Unicode>(SAL_PATHSEPARATOR) );
+        if (!systemPath.isEmpty())
+        {
+            if (bAppendSep)
+                bufPYTHONPATH.append(static_cast<sal_Unicode>(SAL_PATHSEPARATOR));
+            bufPYTHONPATH.append(systemPath);
+            bAppendSep = true;
+        }
         if( nNew == -1 )
             break;
         nIndex = nNew + 1;
     }
     const char * oldEnv = getenv( "PYTHONPATH");
     if( oldEnv )
+    {
+        if (bAppendSep)
+            bufPYTHONPATH.append( static_cast<sal_Unicode>(SAL_PATHSEPARATOR) );
         bufPYTHONPATH.append( OUString(oldEnv, strlen(oldEnv), osl_getThreadTextEncoding()) );
+    }
 
     OUString envVar("PYTHONPATH");
     OUString envValue(bufPYTHONPATH.makeStringAndClear());


More information about the Libreoffice-commits mailing list