summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-19 11:32:00 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-06-19 21:14:16 +0200
commit327153471ae38abe90463f6272e00aaa996c5ba3 (patch)
tree71c3249bef17847ee22ef3afe2d25dc9fdb360d6 /pyuno
parent398ba26077f9029bdf6f7378bfc9ce8376b6f02d (diff)
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@redhat.com>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/loader/pyuno_loader.cxx14
1 files changed, 12 insertions, 2 deletions
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());