Index: install.c =================================================================== --- install.c (revision 69040) +++ install.c (working copy) @@ -114,6 +114,7 @@ FILE *logfile; char modulename[MAX_PATH]; +wchar_t wmodulename[MAX_PATH]; HWND hwndMain; HWND hDialog; @@ -299,6 +300,27 @@ typedef void PyObject; +// Convert a "char *" string to "whcar_t *", or NULL on error. +// Result string must be free'd +wchar_t *widen_string(char *src) +{ + wchar_t *result; + DWORD dest_cch; + int src_len = strlen(src) + 1; // include NULL term in all ops + /* use MultiByteToWideChar() to see how much we need. */ + /* NOTE: this will include the null-term in the length */ + dest_cch = MultiByteToWideChar(CP_ACP, 0, src, src_len, NULL, 0); + // alloc the buffer + result = (wchar_t *)malloc(dest_cch * sizeof(wchar_t)); + if (result==NULL) + return NULL; + /* do the conversion */ + if (0==MultiByteToWideChar(CP_ACP, 0, src, src_len, result, dest_cch)) { + free(result); + return NULL; + } + return result; +} /* * Returns number of files which failed to compile, @@ -307,7 +329,7 @@ static int compile_filelist(HINSTANCE hPython, BOOL optimize_flag) { DECLPROC(hPython, void, Py_Initialize, (void)); - DECLPROC(hPython, void, Py_SetProgramName, (char *)); + DECLPROC(hPython, void, Py_SetProgramName, (wchar_t *)); DECLPROC(hPython, void, Py_Finalize, (void)); DECLPROC(hPython, int, PyRun_SimpleString, (char *)); DECLPROC(hPython, PyObject *, PySys_GetObject, (char *)); @@ -326,7 +348,7 @@ return -1; *Py_OptimizeFlag = optimize_flag ? 1 : 0; - Py_SetProgramName(modulename); + Py_SetProgramName(wmodulename); Py_Initialize(); errors += do_compile_files(PyRun_SimpleString, optimize_flag); @@ -697,7 +719,7 @@ run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv) { DECLPROC(hPython, void, Py_Initialize, (void)); - DECLPROC(hPython, int, PySys_SetArgv, (int, char **)); + DECLPROC(hPython, int, PySys_SetArgv, (int, wchar_t **)); DECLPROC(hPython, int, PyRun_SimpleString, (char *)); DECLPROC(hPython, void, Py_Finalize, (void)); DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); @@ -708,6 +730,8 @@ int result = 0; int fh; + static wchar_t *wargv[256]; + int i; if (!Py_Initialize || !PySys_SetArgv || !PyRun_SimpleString || !Py_Finalize) @@ -734,7 +758,16 @@ Py_Initialize(); prepare_script_environment(hPython); - PySys_SetArgv(argc, argv); + // widen the argv array for py3k. + memset(wargv, 0, sizeof(wargv)); + for (i=0;i