diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 0d8d91b4d03cf0..4bc32b71d15da8 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -3284,9 +3284,14 @@ def expect_file(self, name, type=None, symlink_to=None, mode=None): path = pathlib.Path(os.path.normpath(self.destdir / name)) self.assertIn(path, self.expected_paths) self.expected_paths.remove(path) - if mode is not None: + + # When checking mode, ignore Windows (which can only set user read and + # user write bits). Newer versions of Python use `os_helper.can_chmod()` + # instead of hardcoding Windows. + if mode is not None and sys.platform != 'win32': got = stat.filemode(stat.S_IMODE(path.stat().st_mode)) self.assertEqual(got, mode) + if type is None and isinstance(name, str) and name.endswith('/'): type = tarfile.DIRTYPE if symlink_to is not None: