Fixed string mangling from dirname

This commit is contained in:
Vincent Castellano 2015-05-18 13:32:58 -07:00
parent 1ca2fe6941
commit 36d5465d81

View File

@ -1320,6 +1320,9 @@ void py_init (const char *file) {
PyObject* sysPath = PySys_GetObject((char*)"path"); PyObject* sysPath = PySys_GetObject((char*)"path");
PyList_Append(sysPath, PyUnicode_FromString(dirname(filename))); PyList_Append(sysPath, PyUnicode_FromString(dirname(filename)));
// Recopy the string in, since dirname modified it.
strncpy(filename, file, 1024);
// remove .py extension from file, if any // remove .py extension from file, if any
char* dot = strrchr(filename, '.'); char* dot = strrchr(filename, '.');
if (dot && strcmp(dot, ".py") == 0) if (dot && strcmp(dot, ".py") == 0)