Skip to content

[3.14] gh-161705: Prevent shadowing stdlib in gzip/tarfile/zipfile CLI (#161706) - #161719

Merged
vstinner merged 1 commit into
python:3.14from
vstinner:sys_path0_14
Nov 10, 2026
Merged

vstinner merged 1 commit into
python:3.14from
vstinner:sys_path0_14

Conversation

@vstinner

@vstinner vstinner commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Remove sys.path[0] in gzip, tarfile and zipfile command line interface to prevent shadowing standard library modules from extracted files.

  • Add sys._path0 variable.
  • pymain_sys_path_add_path0() sets sys._path0.
  • Add runpy._remove_sys_path0().
  • gzip, tarfile and zipfile main functions now call _remove_sys_path0() to prevent shadowing stdlib modules from extracted files.

(cherry picked from commit e891a91)

…python#161706)

Remove sys.path[0] in gzip, tarfile and zipfile command line
interface to prevent shadowing standard library modules from
extracted files.

* Add sys._path0 variable.
* pymain_sys_path_add_path0() sets sys._path0.
* Add runpy._remove_sys_path0().
* gzip, tarfile and zipfile main functions now call
  _remove_sys_path0() to prevent shadowing stdlib modules from
  extracted files.

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
(cherry picked from commit e891a91)
@vstinner
vstinner enabled auto-merge (squash) November 10, 2026 00:09
@vstinner
vstinner merged commit 8aa5d65 into python:3.14 Nov 10, 2026
62 checks passed
@vstinner
vstinner deleted the sys_path0_14 branch November 10, 2026 00:35
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12, 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.13 due to a conflict.

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

cherry_picker 8aa5d657e4d3f1a4cca5ff6c976e2e868e0a9056 3.13

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.12 due to a conflict.

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

cherry_picker 8aa5d657e4d3f1a4cca5ff6c976e2e868e0a9056 3.12

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.11 due to a conflict.

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

cherry_picker 8aa5d657e4d3f1a4cca5ff6c976e2e868e0a9056 3.11

@bedevere-app

bedevere-app Bot commented Nov 10, 2026

Copy link
Copy Markdown

GH-161726 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant