[pywin32-checkins] pywin32/win32/src PythonService.cpp,1.26,1.27
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-02-07 00:32:33
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21610 Modified Files: PythonService.cpp Log Message: fix argv handling now we always build as UNICODE Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PythonService.cpp 28 Dec 2008 10:43:45 -0000 1.26 --- PythonService.cpp 7 Feb 2009 00:32:30 -0000 1.27 *************** *** 590,593 **** --- 590,602 ---- } + static char *NarrowString(WCHAR *s) + { + int cchNarrow = WideCharToMultiByte(CP_ACP, 0, s, -1, NULL, 0, NULL, NULL); + char *ret = (char *)malloc(cchNarrow); + if (ret) + WideCharToMultiByte(CP_ACP, 0, s, -1, ret, cchNarrow, NULL, NULL); + return ret; + } + // Couple of helpers for the service manager static void PyService_InitPython() *************** *** 604,614 **** int pyargc; #if (PY_VERSION_HEX < 0x03000000) ! pyargc = __argc; ! char **pyargv = __argv; #else ! WCHAR **pyargv; ! pyargv = CommandLineToArgvW(GetCommandLineW(), &pyargc); #endif ! Py_SetProgramName(pyargv[0]); #ifdef BUILD_FREEZE --- 613,631 ---- int pyargc; #if (PY_VERSION_HEX < 0x03000000) ! pyargc = 0; ! char **pyargv = (char **)malloc(sizeof(char *) * __argc); ! if (pyargv) { ! for (;pyargc<__argc;pyargc++) { ! pyargv[pyargc] = NarrowString(__wargv[pyargc]); ! if (!pyargv[pyargc]) { ! break; ! } ! } ! } #else ! WCHAR **pyargv = CommandLineToArgvW(GetCommandLineW(), &pyargc); #endif ! if (pyargv) ! Py_SetProgramName(pyargv[0]); #ifdef BUILD_FREEZE *************** *** 621,627 **** // Ensure we are set for threading. PyEval_InitThreads(); ! PySys_SetArgv(pyargc, pyargv); #if (PY_VERSION_HEX < 0x03000000) initservicemanager(); #else PyInit_servicemanager(); --- 638,654 ---- // Ensure we are set for threading. PyEval_InitThreads(); ! // Notes about argv: When debugging a service, the argv is currently ! // the *full* args, including the "-debug servicename" args. This ! // isn't ideal, but has been this way for a few builds, and a good ! // fix isn't clear - should 'servicename' be presented in argv, even ! // though it never is when running as a real service? ! if (pyargv) ! PySys_SetArgv(pyargc, pyargv); #if (PY_VERSION_HEX < 0x03000000) initservicemanager(); + // free the argv we created above + for (int i=0;i<pyargc;i++) + free(pyargv[i]); + free(pyargv); #else PyInit_servicemanager(); |