This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients barry, ncoghlan, palm.kevin, pitrou, srid, tarek, vstinner
Date 2011-03-17.23:31:53
SpamBayes Score 0.000349112
Marked as misclassified No
Message-id <1300404714.4.0.515634630318.issue11320@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2011-03-17 23:31:54pitrousetrecipients: + pitrou, barry, ncoghlan, vstinner, tarek, srid, palm.kevin
2011-03-17 23:31:54pitrousetmessageid: <1300404714.4.0.515634630318.issue11320@psf.upfronthosting.co.za>
2011-03-17 23:31:53pitroulinkissue11320 messages
2011-03-17 23:31:53pitroucreate