TarFile.extract raises DeprecationWarning since Python 3.12 #6657
Labels
good first issue
Issues that should be relatively easy to fix also for beginning contributors
help wanted
priority/important
topic/archive
type/enhancement
Issue
Calls to stdlib
tar.TarFile.extract
(ortar.TarFile.extractall
) started raising the following DeprecationWarning since Python 3.12In general, extracting untrusted tarfiles is an unsafe operation (since the tarfile can contain relative paths (e.g.
../malicious_file.txt
) or absolute paths to known locations. See PEP 706, which added thefilter
argument toextract
methods in Python 3.12. When this argument is omitted a DeprecationWarning is raised.Solution
Documentation on extraction filters
See this section of the PEP how to deal with this in a backwards compatible manner
https://peps.python.org/pep-0706/#backporting-forward-compatibility
Open questions
Which filter should we use by default? Probably
data
, which is recommended and will be default since 3.14.Your environment
The text was updated successfully, but these errors were encountered: