diff PyPlugScanner.cpp @ 108:efff8e5d90a3

Set sys.argv - avoiding Python code blowing up if it checks sys.argv[0] without checking sys.argv exists first. Patch due to Johan Pauwels
author Chris Cannam
date Tue, 12 Feb 2019 11:27:02 +0000
parents 2f2292b029a4
children a9e918adfff0
line wrap: on
line diff
--- a/PyPlugScanner.cpp	Wed Jan 16 15:47:57 2019 +0000
+++ b/PyPlugScanner.cpp	Tue Feb 12 11:27:02 2019 +0000
@@ -145,7 +145,10 @@
 PyPlugScanner::getScriptClass(string path, string classname)
 {
 	//Add plugin path to active Python Path 
-	string pyCmd = "import sys\nsys.path.append('" + path + "')\n";
+	string pyCmd =
+		"import sys\n"
+		"sys.path.append('" + path + "')\n"
+		"sys.argv = ['" + classname + "']\n";
 	PyRun_SimpleString(pyCmd.c_str());
 
 	//Assign an object to the source code