Mercurial > cpython-lru_cache-weakref
diff Modules/main.c @ 51560:cab4e2e484a2 3.0
Merged revisions 69540 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r69540 | ronald.oussoren | 2009-02-12 16:55:38 +0100 (Thu, 12 Feb 2009) | 5 lines
This fixes issue5143 and includes a test.
Issue5143 notes that getpath.c and main.c pass a 'char*' where
a 'wchar_t*' is expected on OSX.
........
| author | Ronald Oussoren <ronaldoussoren@mac.com> |
|---|---|
| date | Thu, 12 Feb 2009 15:56:48 +0000 |
| parents | b98fe8dc8acd |
| children | ff6eea017a7f |
line wrap: on
line diff
--- a/Modules/main.c Thu Feb 12 15:27:00 2009 +0000 +++ b/Modules/main.c Thu Feb 12 15:56:48 2009 +0000 @@ -487,10 +487,23 @@ so the actual executable path is passed in an environment variable. See Lib/plat-mac/bundlebuiler.py for details about the bootstrap script. */ - if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') - Py_SetProgramName(p); - else + if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') { + wchar_t* buffer; + size_t len = strlen(p); + size_t r; + + buffer = malloc(len * sizeof(wchar_t)); + if (buffer == NULL) { + Py_FatalError( + "not enough memory to copy PYTHONEXECUTABLE"); + } + + r = mbstowcs(buffer, p, len); + Py_SetProgramName(buffer); + /* buffer is now handed off - do not free */ + } else { Py_SetProgramName(argv[0]); + } #else Py_SetProgramName(argv[0]); #endif
