Thanks to visit codestin.com
Credit goes to github.com

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 May 16, 2023
commit 6da78bfe2575cd25a9e11d343bc37f2c336a7514
5 changes: 0 additions & 5 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2191,11 +2191,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 @@ -1494,8 +1494,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 sha256
from contextlib import contextmanager, ExitStack
from contextlib import contextmanager
from random import Random
import pathlib
import shutil
Expand Down Expand Up @@ -2736,10 +2736,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 @@ -3373,12 +3370,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