Skip to content

Commit 5bf4a48

Browse files
committed
Add ENAMETOOLONG to expected failures. And an extra subTest.
1 parent a124c42 commit 5bf4a48

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Lib/test/test_tarfile.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,13 +3827,19 @@ def test_realpath_limit_attack(self):
38273827
# we can also create new files as well!
38283828
arc.add("escape/newfile", content='new')
38293829

3830-
with self.check_context(arc.open(), filter='fully_trusted',
3831-
check_flag=False):
3830+
with (self.subTest('fully_trusted'),
3831+
self.check_context(arc.open(), filter='fully_trusted',
3832+
check_flag=False)):
38323833
if sys.platform == 'win32':
38333834
self.expect_exception((FileNotFoundError, FileExistsError))
38343835
elif self.raised_exception:
38353836
# Most likely, guess for number of components was wrong?
3836-
self.expect_exception(KeyError)
3837+
try:
3838+
raise self.raised_exception
3839+
except KeyError:
3840+
pass
3841+
except OSError as exc:
3842+
self.assertEqual(exc.errno, errno.ENAMETOOLONG)
38373843
elif os_helper.can_symlink() and os_helper.can_hardlink():
38383844
self.expect_any_tree(component)
38393845
self.expect_file('flaglink', content='overwrite')

0 commit comments

Comments
 (0)