-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEP 721: Use the data_filter
when extracting tarballs, if it's available.
#12214
Conversation
I feel it may be a good idea to pull the except and else blocks into separate functions for readability. It’s difficult for me to find where the except block ends now. |
Needs same fix as pypa/build#675 to avoid breakage. |
(This is still on my TODO list, it just keeps getting pushed back by conferences.) |
Sorry for the delay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would break some existing code. Do we want to add a flag to allow users to disable data_filter
temporarily? Or should we treat those as security issues and allow breakage?
…ailable. Previous behaviour is used on Python without PEP-720 tarfile filters. (Note that the feature is now in security releases of all supported versions.) A custom filter (which wraps `data_filter`) is used to retain pip-specific behaviour: - Removing a common leading directory - Setting the mode (Unix permissions) Compared to the previous behaviour, if a file can't be unpacked, the unpacking operation will fail with `InstallError`, rather than skipping the individual file with a `logger.warning`. This means that "some corrupt tar files" now can't be unpacked. Note that PEP 721 limits itself to sdists, this change affects unpacking any other tar file.
The latter, IMO. |
Previous behaviour is used on Python without PEP-720 tarfile filters. (Note that the feature is now in security releases of all supported versions.)
A custom filter (which wraps
data_filter
) is used to retain pip-specific behaviour:Compared to the previous behaviour, if a file can't be unpacked, the unpacking operation will fail with
InstallError
, rather than skipping the individual file with alogger.warning
. This means that "some corrupt tar files" now can't be unpacked.IMO, this is the correct path forward, but maybe there should be a CLI option to use the old behaviour? Sadly I don't know enough about pip to add one and propagate the setting to
untar_file
.The new code path avoids internal API (
TarFile._extract_member
).Note that PEP 721 limits itself to sdists, this change affects unpacking any other tar file.
I hope I got the
nox
/mypy
/ruff
stuff right, guess CI will tell...This PR indents a big block of code. To hide whitespace changes, use
git diff -w
or add?w=1
to the GitHub URL.Fixes: #12111