Fix crash with flt2egg

This commit is contained in:
rdb 2009-07-24 09:01:20 +00:00
parent 8460b7dd3d
commit a457d59aae

View File

@ -214,7 +214,7 @@ ns_get_environment_variable(const string &var) const {
} else if (var == "MAIN_DIR") { } else if (var == "MAIN_DIR") {
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
// If we're running from Python code, read out sys.argv. // If we're running from Python code, read out sys.argv.
if (PyObject* obj = PySys_GetObject((char*) "argv")) { if (Py_IsInitialized() && PyObject* obj = PySys_GetObject((char*) "argv")) {
Filename main_dir (PyString_AsString(PyList_GetItem(obj, 0))); Filename main_dir (PyString_AsString(PyList_GetItem(obj, 0)));
if (main_dir.empty()) { if (main_dir.empty()) {
// We must be running in the Python interpreter directly, so return the CWD. // We must be running in the Python interpreter directly, so return the CWD.