@@ -3804,22 +3804,19 @@ def __exit__(self, *exc_info):
3804
3804
def test_errorlevel (self ):
3805
3805
def extracterror_filter (tarinfo , path ):
3806
3806
raise tarfile .ExtractError ('failed with ExtractError' )
3807
- def tarerror_filter (tarinfo , path ):
3808
- raise tarfile .ExtractError ('failed with base TarError' )
3809
3807
def filtererror_filter (tarinfo , path ):
3810
3808
raise tarfile .FilterError ('failed with FilterError' )
3811
3809
def oserror_filter (tarinfo , path ):
3812
3810
raise OSError ('failed with OSError' )
3811
+ def tarerror_filter (tarinfo , path ):
3812
+ raise tarfile .TarError ('failed with base TarError' )
3813
3813
def valueerror_filter (tarinfo , path ):
3814
3814
raise ValueError ('failed with ValueError' )
3815
3815
3816
3816
with ArchiveMaker () as arc :
3817
3817
arc .add ('file' )
3818
3818
3819
- # If errorlevel is 0, errors are ignored when using TarFile.extract().
3820
-
3821
- with self .check_context (arc .open (errorlevel = 0 ), tarerror_filter ):
3822
- self .expect_file ('file' )
3819
+ # If errorlevel is 0, errors affected by errorlevel are ignored
3823
3820
3824
3821
with self .check_context (arc .open (errorlevel = 0 ), extracterror_filter ):
3825
3822
self .expect_file ('file' )
@@ -3830,14 +3827,14 @@ def valueerror_filter(tarinfo, path):
3830
3827
with self .check_context (arc .open (errorlevel = 0 ), oserror_filter ):
3831
3828
self .expect_file ('file' )
3832
3829
3830
+ with self .check_context (arc .open (errorlevel = 0 ), tarerror_filter ):
3831
+ self .expect_exception (tarfile .TarError )
3832
+
3833
3833
with self .check_context (arc .open (errorlevel = 0 ), valueerror_filter ):
3834
3834
self .expect_exception (ValueError )
3835
3835
3836
3836
# If 1, all fatal errors are raised
3837
3837
3838
- with self .check_context (arc .open (errorlevel = 1 ), tarerror_filter ):
3839
- self .expect_file ('file' )
3840
-
3841
3838
with self .check_context (arc .open (errorlevel = 1 ), extracterror_filter ):
3842
3839
self .expect_file ('file' )
3843
3840
@@ -3847,14 +3844,14 @@ def valueerror_filter(tarinfo, path):
3847
3844
with self .check_context (arc .open (errorlevel = 1 ), oserror_filter ):
3848
3845
self .expect_exception (OSError )
3849
3846
3847
+ with self .check_context (arc .open (errorlevel = 1 ), tarerror_filter ):
3848
+ self .expect_exception (tarfile .TarError )
3849
+
3850
3850
with self .check_context (arc .open (errorlevel = 1 ), valueerror_filter ):
3851
3851
self .expect_exception (ValueError )
3852
3852
3853
3853
# If 2, all non-fatal errors are raised as well.
3854
3854
3855
- with self .check_context (arc .open (errorlevel = 2 ), tarerror_filter ):
3856
- self .expect_exception (tarfile .TarError )
3857
-
3858
3855
with self .check_context (arc .open (errorlevel = 2 ), extracterror_filter ):
3859
3856
self .expect_exception (tarfile .ExtractError )
3860
3857
@@ -3864,12 +3861,15 @@ def valueerror_filter(tarinfo, path):
3864
3861
with self .check_context (arc .open (errorlevel = 2 ), oserror_filter ):
3865
3862
self .expect_exception (OSError )
3866
3863
3864
+ with self .check_context (arc .open (errorlevel = 2 ), tarerror_filter ):
3865
+ self .expect_exception (tarfile .TarError )
3866
+
3867
3867
with self .check_context (arc .open (errorlevel = 2 ), valueerror_filter ):
3868
3868
self .expect_exception (ValueError )
3869
3869
3870
- # We only handle TarError & OSError specially.
3870
+ # We only handle ExtractionError, FilterError & OSError specially.
3871
3871
3872
- with self .check_context (arc .open (errorlevel = 'boo!' ), tarerror_filter ):
3872
+ with self .check_context (arc .open (errorlevel = 'boo!' ), filtererror_filter ):
3873
3873
self .expect_exception (TypeError ) # errorlevel is not int
3874
3874
3875
3875
0 commit comments