Mercurial > cpython-lru_cache-weakref
diff Modules/getpath.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 | cd61d54fc8c0 |
| children | 7e3b490877ce 9b5806a008e7 |
line wrap: on
line diff
--- a/Modules/getpath.c Thu Feb 12 15:27:00 2009 +0000 +++ b/Modules/getpath.c Thu Feb 12 15:56:48 2009 +0000 @@ -457,6 +457,7 @@ #else unsigned long nsexeclength = MAXPATHLEN; #endif + char execpath[MAXPATHLEN+1]; #endif if (_path) { @@ -486,8 +487,13 @@ * will fail if a relative path was used. but in that case, * absolutize() should help us out below */ - else if(0 == _NSGetExecutablePath(progpath, &nsexeclength) && progpath[0] == SEP) - ; + else if(0 == _NSGetExecutablePath(execpath, &nsexeclength) && execpath[0] == SEP) { + size_t r = mbstowcs(progpath, execpath, MAXPATHLEN+1); + if (r == (size_t)-1 || r > MAXPATHLEN) { + /* Could not convert execpath, or it's too long. */ + progpath[0] = '\0'; + } + } #endif /* __APPLE__ */ else if (path) { while (1) {
