Skip to content

🐛 fix(seed): launch pip in legacy locales - #3681

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/legacy-locale-pip-nu6
Nov 20, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/legacy-locale-pip-nu6

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

At the merge base, the app-data seeder kept a direct pip launcher header when it fit on one line, even if the interpreter's filesystem bytes differed from UTF-8. The pip seeder also left such a header in place unless the path contained whitespace. In a legacy POSIX locale, bin/pip then names a different path and usually fails to start, while python -m pip works. Both seeders now make the launcher start the environment's interpreter. Fixes #3632.

The header used a different byte spelling

distlib's script maker encodes the interpreter path as UTF-8. The kernel uses the shebang's bytes to find that path, while Python reads the launcher as UTF-8. The codec check compares the filesystem bytes with UTF-8. On a mismatch, the shell wrapper uses ASCII octal escapes so /bin/sh reconstructs the absolute interpreter path. The app-data seeder selects that wrapper when the bytes differ.

The pip seeder needed the same rewrite

The rewriter now also selects pip's direct header when the path bytes differ, replaces it with the same shell wrapper, and refreshes its RECORD entry. The activation check in #3412 and Xonsh changes in #3667, #3668, and #3671 concern activation scripts; they do not change direct seeded launchers.

Behavior changes

In a non-UTF-8 POSIX locale, seeded pip launchers work for non-ASCII paths whose filesystem bytes differ from UTF-8. Matching paths keep their existing header form, and Windows launcher handling is unchanged. Pip can still write mismatched launchers for packages installed later or after a pip upgrade. Real aa_DJ.iso88591 tests cover both seeders with non-ASCII names, spaces, and shell punctuation; a raw byte path test covers surrogate escapes.

Reported by oss-scanner: ANT-2026-NU6BEMWZ.

@gaborbernat
gaborbernat force-pushed the fix/legacy-locale-pip-nu6 branch 2 times, most recently from f7015b4 to 7634987 Compare November 20, 2026 09:10
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 10:09
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 10:13
POSIX launchers encoded environment paths as UTF-8 even when their
filesystem bytes used a legacy locale. The kernel then looked for an
interpreter at a different path.

Use an ASCII shell wrapper to reconstruct the interpreter's filesystem
bytes for both seeders.

Fixes pypa#3632
@gaborbernat
gaborbernat force-pushed the fix/legacy-locale-pip-nu6 branch from 7634987 to 2f3763c Compare November 20, 2026 10:17
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 10:40
@gaborbernat
gaborbernat merged commit a0b0b6f into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/legacy-locale-pip-nu6 branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seeded pip launchers use wrong path bytes in legacy locales

1 participant