[pywin32-checkins] pywin32/win32/src PythonService.cpp,1.16,1.17
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-03-31 00:21:11
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1966 Modified Files: PythonService.cpp Log Message: Fix "[ 1064265 ] Having system32 in sys.path causes problems for services" by having pythonservice.pyd change the current directory before initializing Python. Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PythonService.cpp 11 Oct 2004 06:17:49 -0000 1.16 --- PythonService.cpp 31 Mar 2005 00:21:01 -0000 1.17 *************** *** 1020,1024 **** targv = argv; #endif ! if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) --- 1020,1035 ---- targv = argv; #endif ! // Before we start, change directory to our executable's dir. This ! // is to prevent our cwd being SYSTEM32, which can have undesired ! // side effects (ie, it ends up on sys.path and, eg, 'import zlib' may ! // locate zlib.dll in that directory rather than the correct zlib.pyd. ! TCHAR dir[MAX_PATH] = _T(""); ! GetModuleFileName(0, dir, sizeof(dir)/sizeof(dir[0])); ! TCHAR *slash = _tcsrchr(dir, _T('\\')); ! if (slash) { ! *slash = '\0'; ! _tchdir(dir); ! } ! // Process the args if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) |