[Python-checkins] bpo-38353: Fix calculate_argv0_path() for symlinks (GH-16549)

Victor Stinner webhook-mailer at python.org
Thu Oct 3 17:17:04 EDT 2019


https://github.com/python/cpython/commit/86ec5c65fe04ece16f3aada5292cc62726062ad0
commit: 86ec5c65fe04ece16f3aada5292cc62726062ad0
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2019-10-03T23:17:00+02:00
summary:

bpo-38353: Fix calculate_argv0_path() for symlinks (GH-16549)

calculate_argv0_path() must read argv0_path link, not read
program_full_path link.

files:
M Modules/getpath.c

diff --git a/Modules/getpath.c b/Modules/getpath.c
index 4246d4ca5ac0d..fca87c7b0ee93 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -959,7 +959,7 @@ calculate_argv0_path(PyCalculatePath *calculate, const wchar_t *program_full_pat
 #if HAVE_READLINK
     wchar_t tmpbuffer[MAXPATHLEN + 1];
     const size_t buflen = Py_ARRAY_LENGTH(tmpbuffer);
-    int linklen = _Py_wreadlink(program_full_path, tmpbuffer, buflen);
+    int linklen = _Py_wreadlink(argv0_path, tmpbuffer, buflen);
     while (linklen != -1) {
         if (_Py_isabs(tmpbuffer)) {
             /* tmpbuffer should never be longer than MAXPATHLEN,



More information about the Python-checkins mailing list