gh-154160: Make sys.executable absolute when resolved from a relative PATH entry#154163
Open
fedonman wants to merge 1 commit into
Open
gh-154160: Make sys.executable absolute when resolved from a relative PATH entry#154163fedonman wants to merge 1 commit into
fedonman wants to merge 1 commit into
Conversation
…lative PATH entry When the interpreter is started by a bare program name and found through a relative directory in PATH, getpath left sys.executable as that relative path, contrary to its documented behaviour of being an absolute path. This is a regression from the getpath.c rewrite in 3.11. Absolutize the executable resolved from PATH, matching the sibling branch that already calls abspath() when the program name itself contains a separator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sys.executableis documented as "a string giving the absolute path of the executable binary for the Python interpreter". When the interpreter is started by a bare program name (no separator) and found through a relative directory inPATH, it was left as that relative path instead:getpathabsolutizes the executable in the sibling branch that handles a program name containing a separator (executable = abspath(program_name)), but the PATH-resolution loop assigned the joined path directly. This makes it callabspath()there too:This is a regression from the getpath.c rewrite in 3.11 (bpo-45582 / #29041); 3.10 returned an absolute path.
The issue also notes a separate, cosmetic double-slash case (
//usr/local/bin/python3when invoked asusr/local/bin/python3from/); that comes from a different branch and is not addressed here.