Skip to content
Closed
Prev Previous commit
Next Next commit
Remove the DeprecationWarning
  • Loading branch information
encukou committed May 17, 2023
commit 3ab896be0b764dc7feddd08b92052ec544410d5a
5 changes: 0 additions & 5 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,11 +2164,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 @@ -1275,8 +1275,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 support.check_warnings(
('The default', RuntimeWarning)):
with support.check_no_warnings(self):
self.check_unpack_archive(format)

def test_unpack_archive_tar(self):
Expand Down
14 changes: 5 additions & 9 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 md5
from contextlib import contextmanager, ExitStack
from contextlib import contextmanager
from random import Random
import pathlib
import shutil
Expand Down Expand Up @@ -2726,10 +2726,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())
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 @@ -3363,12 +3360,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 support.check_warnings(
('Python 3.14', DeprecationWarning)):
with support.check_no_warnings(self):
with self.check_context(arc.open(), None):
self.expect_file('foo')

Expand Down