zoneinfo.rebuild: Extract using tarfile data filter (PEP 706) if available #1295
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.
Summary of changes
In new versions of Python,
tarfile
allows filters (PEP-706), a mechanism to limit allowed features when extracting tarballs. Thedata
filter, suggested here, is intended for pure data files. A cross-platform tarball like atzdata
release definitely should not need more. Details on what it does are here.This uses the mechanism if it's available.
The incantation, a bit convoluted in order to be backwards-compatible, is taken from the docs.
Pull Request Checklist
Changes have tests
The can be reproduced using
python3.12 -Werror updatezinfo.py
, which fails with aDeprecationWarning
error.The code is called in the release process/test setup, rather than tests themselves. Also, 3.12 is not in the CI matrix yet.
If you think manual testing isn't enough, I'd appreciate pointers on how to test this.
Authors have been added to AUTHORS.md
I'm fine without that, if it's OK with you.
News fragment added in changelog.d. See CONTRIBUTING.md for details