Mercurial > hg > vampy
comparison 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 |
comparison
equal
deleted
inserted
replaced
100:08dd88201115 | 108:efff8e5d90a3 |
---|---|
143 //This should not be called more than once! | 143 //This should not be called more than once! |
144 PyObject* | 144 PyObject* |
145 PyPlugScanner::getScriptClass(string path, string classname) | 145 PyPlugScanner::getScriptClass(string path, string classname) |
146 { | 146 { |
147 //Add plugin path to active Python Path | 147 //Add plugin path to active Python Path |
148 string pyCmd = "import sys\nsys.path.append('" + path + "')\n"; | 148 string pyCmd = |
149 "import sys\n" | |
150 "sys.path.append('" + path + "')\n" | |
151 "sys.argv = ['" + classname + "']\n"; | |
149 PyRun_SimpleString(pyCmd.c_str()); | 152 PyRun_SimpleString(pyCmd.c_str()); |
150 | 153 |
151 //Assign an object to the source code | 154 //Assign an object to the source code |
152 PyObject *pySource = PyString_FromString(classname.c_str()); | 155 PyObject *pySource = PyString_FromString(classname.c_str()); |
153 | 156 |