Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove the DeprecationWarning
  • Loading branch information
encukou committed Apr 25, 2023
commit ce00e6d3fcac1e77f0eac3df48eed37e1badf4d3
5 changes: 0 additions & 5 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2214,11 +2214,6 @@ def _get_filter_function(self, filter):
if filter is None:
filter = self.extraction_filter
if filter is None:
warnings.warn(
'Python 3.14 will, by default, filter extracted tar '
+ 'archives and reject files or modify their metadata. '
+ 'Use the filter argument to control this behavior.',
DeprecationWarning)
return fully_trusted_filter
if isinstance(filter, str):
raise TypeError(
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,7 @@ def check_unpack_archive_with_converter(self, format, converter, **kwargs):
def check_unpack_tarball(self, format):
self.check_unpack_archive(format, filter='fully_trusted')
self.check_unpack_archive(format, filter='data')
with warnings_helper.check_warnings(
('Python 3.14', DeprecationWarning)):
with warnings_helper.check_no_warnings(self):
self.check_unpack_archive(format)

def test_unpack_archive_tar(self):
Expand Down
15 changes: 5 additions & 10 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import io
from hashlib import sha256
from contextlib import contextmanager, ExitStack
from contextlib import contextmanager
from random import Random
import pathlib
import shutil
Expand Down Expand Up @@ -2994,11 +2994,7 @@ def setUpClass(cls):
tar = tarfile.open(tarname, mode='r', encoding="iso8859-1")
cls.control_dir = pathlib.Path(TEMPDIR) / "extractall_ctrl"
tar.errorlevel = 0
with ExitStack() as cm:
if cls.extraction_filter is None:
cm.enter_context(warnings.catch_warnings(
action="ignore", category=DeprecationWarning))
tar.extractall(cls.control_dir, filter=cls.extraction_filter)
tar.extractall(cls.control_dir, filter=cls.extraction_filter)
tar.close()
cls.control_paths = set(
p.relative_to(cls.control_dir)
Expand Down Expand Up @@ -3649,12 +3645,11 @@ def test_data_filter(self):
self.assertIs(filtered.name, tarinfo.name)
self.assertIs(filtered.type, tarinfo.type)

def test_default_filter_warns(self):
"""Ensure the default filter warns"""
def test_default_filter_warns_not(self):
"""Ensure the default filter does not warn (like in 3.12)"""
with ArchiveMaker() as arc:
arc.add('foo')
with warnings_helper.check_warnings(
('Python 3.14', DeprecationWarning)):
with warnings_helper.check_no_warnings(self):
with self.check_context(arc.open(), None):
self.expect_file('foo')

Expand Down