Prevent uninstalling site-packages for empty .egg-info top_level.txt#19114
Open
nooscraft wants to merge 2 commits intoastral-sh:mainfrom
Open
Prevent uninstalling site-packages for empty .egg-info top_level.txt#19114nooscraft wants to merge 2 commits intoastral-sh:mainfrom
nooscraft wants to merge 2 commits intoastral-sh:mainfrom
Conversation
Checks that uninstall ignores blank or whitespace-only lines in top_level.txt, still removes valid entries, and does not touch site-packages.
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.
uv pip uninstall
<pkg>against a legacy.egg-infodistribution with an emptytop_level.txtcould resolve "" back to the distribution location itself and end up deleting site-packages.In
uninstall_eggcrate, each line fromtop_level.txtis now trimmed and empty entries are skipped before iterating. Applied the same trim + non-empty handling tonamespace_packages.txtso both files are parsed consistently. I did not also change is_path_in_scheme to reject paths equal to a scheme root, since that is a broader defense-in-depth change and outside the scope of this fix.Covered by
test_uninstall_egg_info_empty_top_levelnext to the existingtest_uninstall_egg_info_path_traversal, plustest_uninstall_egg_info_blank_lines_in_top_levelfor blank and whitespace-only lines between valid entries, which hits the same wipe path before the fix. It fails on main with uninstall must not remove site-packages itself and passes with this fix. Existinguninstall_egg_info,dry_run_uninstall_egg_info, anduninstall_legacy_editableintegration tests still pass.Closes #19113.