Repository navigation
gh-159819: Fix python-config.sh for installation paths containing spaces - #159820
Merged
Merged
Conversation
…ng spaces The shell variant of python-config located its own installation prefix with unquoted command substitutions, so a prefix containing whitespace was word-split: the script printed empty --prefix and --exec-prefix values and bogus --includes/--ldflags paths while still exiting 0. Quote the substitutions, quote the argument loop, and exit with status 1 when the prefix cannot be determined.
Replace the configured prefix with the installed one using POSIX parameter expansion instead of sed, so that a prefix containing '#', '&', a backslash or a regular expression metacharacter is handled literally.
itamaro
marked this pull request as draft
October 20, 2026 00:14
itamaro
force-pushed
the
fix-python-config-spaces
branch
from
October 20, 2026 00:16
6ddaf7a to
de30d4a
Compare
itamaro
marked this pull request as ready for review
October 20, 2026 00:18
ambv
approved these changes
Oct 21, 2026
dash's echo interprets backslash escapes even in quoted arguments, so a path containing "\c" was truncated. Print every value with printf '%s\n'. Test "#", "&" and "\" in the install path and in the configured prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @itamaro for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @itamaro, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-160184 is a backport of this pull request to the 3.15 branch. |
itamaro
added a commit
that referenced
this pull request
Oct 22, 2026
…ing spaces (GH-159820) (#160184) gh-159819: Fix python-config.sh for installation paths containing spaces (GH-159820) The shell `python-config` located its own prefix with unquoted command substitutions, so any whitespace in the installation path made it print an empty `--prefix` and `-I/include/...`-style paths while exiting 0. - Quote the substitutions and the argument loop (POSIX `sh`, no bashisms). - Exit 1 with a message when the script's directory cannot be resolved, instead of silently printing empty paths. - Replace `sed "s#$prefix#$prefix_real#"` with a `relocate` helper using parameter expansion, so `#`, `&`, `\` and regex metacharacters in either prefix are handled literally. Same first-occurrence semantics. - Add `test_python_config_sh_prefix_with_spaces`: runs the generated script from `…/path with spaces/bin/` and checks `--prefix`, `--exec-prefix`, `--includes` and empty stderr (cherry picked from commit 3e13407) Co-authored-by: Itamar Oren <itamarost@gmail.com>
|
GH-160240 is a backport of this pull request to the 3.14 branch. |
itamaro
added a commit
that referenced
this pull request
Oct 22, 2026
…ing spaces (GH-159820) (#160240) The shell `python-config` located its own prefix with unquoted command substitutions, so any whitespace in the installation path made it print an empty `--prefix` and `-I/include/...`-style paths while exiting 0. - Quote the substitutions and the argument loop (POSIX `sh`, no bashisms). - Exit 1 with a message when the script's directory cannot be resolved, instead of silently printing empty paths. - Replace `sed "s#$prefix#$prefix_real#"` with a `relocate` helper using parameter expansion, so `#`, `&`, `\` and regex metacharacters in either prefix are handled literally. Same first-occurrence semantics. - Add `test_python_config_sh_prefix_with_spaces`: runs the generated script from `…/path with spaces/bin/` and checks `--prefix`, `--exec-prefix`, `--includes` and empty stderr (cherry picked from commit 3e13407)
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.
The shell
python-configlocated its own prefix with unquoted commandsubstitutions, so any whitespace in the installation path made it print an
empty
--prefixand-I/include/...-style paths while exiting 0.sh, no bashisms).instead of silently printing empty paths.
sed "s#$prefix#$prefix_real#"with arelocatehelper usingparameter expansion, so
#,&,\and regex metacharacters in eitherprefix are handled literally. Same first-occurrence semantics.
test_python_config_sh_prefix_with_spaces: runs thegenerated script from
…/path with spaces/bin/and checks--prefix,--exec-prefix,--includesand empty stderrWritten with assistance from Claude Code Fable 5.1
python3-configprints empty or wrong paths when its installation path contains spaces #159819