Message131301
Ok, the issue here is that you can't call Py_SetPath() on the point returned by Py_GetPath(), since the memory refered to that pointer is free()d at the beginning of Py_SetPath(). The following works, though:
main(int argc, char **argv)
{
wchar_t *path, *newpath;
path = Py_GetPath();
newpath = malloc((wcslen(path) + 1) * sizeof(wchar_t));
wcscpy(newpath, path);
Py_SetPath(newpath);
free(newpath);
printf("Init\n");
Py_Initialize();
printf("-- END\n");
}
Perhaps we could modify Py_SetPath() so that it copies the new path first before deallocating the old one, but I'm not sure I see the point of calling Py_SetPath() with the pointer returned by Py_GetPath(). |
|
Date |
User |
Action |
Args |
2011-03-17 23:31:54 | pitrou | set | recipients:
+ pitrou, barry, ncoghlan, vstinner, tarek, srid, palm.kevin |
2011-03-17 23:31:54 | pitrou | set | messageid: <1300404714.4.0.515634630318.issue11320@psf.upfronthosting.co.za> |
2011-03-17 23:31:53 | pitrou | link | issue11320 messages |
2011-03-17 23:31:53 | pitrou | create | |
|