FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-159819: Fix python-config.sh for installation paths containing spaces by itamaro · Pull Request #159820 · python/cpython · GitHub

Repository navigation

gh-159819: Fix python-config.sh for installation paths containing spaces - #159820

Merged
itamaro merged 6 commits into
python:mainfrom
itamaro:fix-python-config-spaces
Oct 22, 2026
Merged

itamaro merged 6 commits into
python:mainfrom
itamaro:fix-python-config-spaces

Conversation

itamaro commented Oct 20, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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

Written with assistance from Claude Code Fable 5.1

…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 requested a review from FFY00 as a code owner October 20, 2026 00:14
itamaro added build The build process and cross-build needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 20, 2026

python-cla-bot Bot commented Oct 20, 2026 •
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

itamaro marked this pull request as ready for review October 20, 2026 00:18
Comment thread Misc/python-config.sh.in Outdated
Comment thread Lib/test/test_sysconfig.py Outdated
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>
itamaro merged commit 3e13407 into python:main Oct 22, 2026
53 checks passed

Copy link
Copy Markdown

Thanks @itamaro for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @itamaro, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 3e134077631fec203e4cdcb44133176d5abbea19 3.14

bedevere-app Bot commented Oct 22, 2026

Copy link
Copy Markdown

GH-160184 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 22, 2026
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

Labels

build The build process and cross-build needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL